Skip to content

Commit 1f96742

Browse files
committed
assets altered
1 parent 5334308 commit 1f96742

4 files changed

Lines changed: 71 additions & 21 deletions

File tree

.assets/matrix rec.mp4

14.1 MB
Binary file not shown.

.assets/matrix_snippet.gif

-11.2 MB
Loading

README.md

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,93 @@
1+
#### **A comprehensive implementation of core **Matrix Decomposition techniques** in Linear Algebra, providing an efficient computation approach, helps in uncovering hidden relationships in data, and lets you power many scalable applications in various fields of science and engineering.**
12

3+
______________________________________________________________________
24

3-
A comprehensive implementation of **_Matrix Decomposition Techniques_**, forming the foundations of various scientific and engineering applications.
5+
To gain a deeper understanding of how Orthogonalization & Matrices Decomposition works in real-life applications, & how they save bunch of time through an approach of vectorization, you'll find such techniques used in;
46

5-
![alt text](.assets/matrix_giphy.gif)
7+
- **📡 Signal Processing**
8+
- **🤖 Control Systems and Robotics**
9+
- **🖼️ Image Processing**
10+
- **➗ Solving Linear Systems i.e. *AX = B***
611

7-
To gain a deeper understanding of how Orthogonalization & matrices Decomposition works in real-life applications, like,
8-
- **Signal Processing**
9-
- **Control Systems and Robotics**
10-
- **Solving Linear Systems i.e. *AX = B***
12+
With certain mathematical intuitions (*having visual introspections*),this project simplifies most of the abstract concepts and becomes easier to grasp and connect with practical applications.
1113

12-
With mathematical intuition & visual introspection, the project makes most of the abstract concepts easier to grasp and connect with practical applications.
14+
![a snippet of notebook](.assets/matrix_snippet.gif)
1315

14-
> This is the first draft of the project. More implementations—such as **Householder Reflection**, **Bidiagonalization**, **LU Decomposition**, and others—will be added soon.
16+
> You'll yet to see more implementations—such as **Householder Reflection**, **Bidiagonalization**, **LU Decomposition**, on this repo, and others—*these will be added soon*.
1517
16-
## Features / What's Inside
18+
## What's Inside
1719

18-
For a vector space, building *Orthonormal Basis* is the most essential part of Linear Algebra.
20+
The **Gram-Schmidt Orthogonalization** is one of the fundamental process in Linear Algebra to achieve *Orthonormal Vectors* for a given vector space. The Orthonormal Basis are produced by iteratively removing vector projections — also known as the *Vector Projection Elimination method*.
1921

20-
You can find top discussions about certain topics like Orthogonality, and why do we need it, ....here.
22+
**Terms like Orthogonality, QR Decomposition are being discussed in the — [🗨️Discussion section](https://github.com/PragyanTiwari/Matrix-Decompositions-Implementation-for-SVD-PCA/discussions).**
2123

22-
#### Gram-Schmidt Orthogonalization
24+
Here's a snippet;
2325

24-
One of the technique for creating Orthonormal Basis from a vector space (*assuming linear independence*) by using a Vector Projection Elimination method.
26+
```bash
27+
def gs_Orthogonalization(X:np.ndarray)->np.ndarray:
28+
29+
Q = np.copy(X).astype("float64")
30+
n_vecs = Q.shape[1]
31+
32+
# defining a function to compute the L2-norm
33+
length = lambda x: np.linalg.norm(x)
34+
35+
# iteration with each vector in the matrix X
36+
for nth_vec in range(n_vecs):
37+
38+
# iteratively removing each preceding projection from nth vector
39+
for k_proj in range(nth_vec):
2540

26-
Here's a snippet,
41+
# the dot product would be the scaler coefficient
42+
scaler = Q[:,nth_vec] @ Q[:,k_proj]
43+
projection = scaler * Q[:,k_proj]
44+
Q[:,nth_vec] -= projection # removing the Kth projection
2745

46+
norm = length(Q[:,nth_vec])
47+
48+
# handling the case if the loop encounters linearly dependent vectors.
49+
# Since, they come already under the span of vector space, hence their value will be 0.
50+
if np.isclose(norm,0, rtol=1e-15, atol=1e-14, equal_nan=False):
51+
Q[:,nth_vec] = 0
52+
else:
53+
# making orthogonal vectors -> orthonormal
54+
Q[:,nth_vec] = Q[:,nth_vec] / norm
55+
56+
return Q
57+
```
58+
59+
To edit the notebook in a sandbox environment, run this;
60+
61+
```bash
62+
uvx marimo edit --sandbox notebooks\Gram_Schmidt_QR_Decomposition.py
63+
```
2864
2965
## 🧪 Testing
3066
31-
To test the export process, run `.github/scripts/build.py` from the root directory.
67+
The updates made on this project, can be tested for deployment, (and for personal experimentation) by the following;
68+
69+
- Fork the repository.
70+
71+
- Run uv sync to install dependencies (*uv lockfile will help*)
3272
3373
```bash
34-
uv run .github/scripts/build.py
74+
uv sync
3575
```
3676
37-
This will export all notebooks in a folder called `_site/` in the root directory. Then to serve the site, run:
77+
- To test the export process, we'll run `.github/scripts/build.py` from the root directory through a symlink.
3878
3979
```bash
40-
python -m http.server -d _site
80+
uv run build.py
4181
```
4282
43-
This will serve the site at `http://localhost:8000`.
83+
This will export all notebooks in a folder called `_site/` in the root directory
84+
85+
## 🌱 Contribution Guide
86+
87+
- If you find a bug or have a feature request, please open an [Issue](https://github.com/PragyanTiwari/Matrix-Decompositions-Implementation-for-SVD-PCA/issues).
88+
89+
- PR will be reviewed by the maintainers.
90+
91+
- Questions & Suggestions can be queried on the [Discussion section](https://github.com/PragyanTiwari/Matrix-Decompositions-Implementation-for-SVD-PCA/discussions).
92+
93+
______________________________________________________________________

notebooks/Gram_Schmidt_QR_Decomposition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# requires-python = ">=3.12"
33
# dependencies = [
44
# "marimo",
5-
# "matplotlib",
6-
# "numpy",
5+
# "matplotlib==3.10.5",
6+
# "numpy==2.3.2",
77
# ]
88
# ///
99
import marimo

0 commit comments

Comments
 (0)