This project demonstrates the implementation of Singular Value Decomposition (SVD) using various popular libraries such as NumPy, SciPy, and PyTorch. Each implementation is contained within its own Jupyter Notebook, providing a comprehensive and detailed guide on how to perform SVD using these different tools.
ository Structure
- Implementation of SVD using NumPy
- Implementation of SVD using SciPy
- Implementation of SVD using PyTorch
The dataset used in this project is the heart_statlog_cleveland_hungary_final.csv
, which combines heart disease data from various sources.
This dataset includes numerous attributes related to heart disease, and it is a common benchmark for evaluating classification algorithms.
To run these notebooks, you will need the following libraries installed in your Python environment:
Library | Version | Implementation |
---|---|---|
NumPy | >= 1.21.0 | All implementations |
SciPy | >= 1.7.0 | SVD_Implement_With_Scipy_NumPy |
PyTorch | >= 1.9.0 | SVD_Implement_With_PyTorch |
Pandas | >= 1.3.0 | All implementations |
Seaborn | >= 0.11.0 | SVD_Implement_With_PyTorch |
TensorFlow | >= 2.5.0 | All implementations |
Matplotlib | >= 3.4.2 | All implementations |
Scikit-Learn | >= 1.0.0 | All implementations |
You can install these dependencies using pip:
pip install numpy scipy torch tensorflow pandas seaborn matplotlib scikit-learn
- Implement With NumPy
This code details the step-by-step process of implementing SVD from scratch using NumPy.
It covers the following steps:
- Data preprocessing
- Custom implementation of matrix transpose
- Custom implementation of eigenvalue decomposition
- Computing the singular values
- Computing left and right singular vectors
- Dimensionality reduction
- Implement With SciPy and NumPy
This code shows how to leverage SciPy's linear algebra capabilities to implement SVD.
It includes:
- Using SciPy for matrix operations
- Performing SVD directly using SciPy's `svd` function
- Verifying the results against the NumPy implementation
- Dimensionality reduction
- Implement With PyTorch
Here, we utilize PyTorch for implementing SVD, which is particularly useful for those familiar with deep learning frameworks.
This notebook covers:
- Utilizing PyTorch tensors for data representation
- Implementing SVD using PyTorch's linear algebra functions
- Comparing performance and results with NumPy and SciPy implementations
- Dimensionality reduction
Each code concludes with a section on results and analysis, where we evaluate the performance of the LDA implementations on the heart disease dataset. We visualize the transformed data and discuss the effectiveness of LDA in dimensionality reduction and classification.
This repository is licensed under the Apache License 2.0. See the LICENSE file for more details.