# pavanng2006-oss/machine-learning-from-scratch architecture

> Architecture diagram of the GitHub repository pavanng2006-oss/machine-learning-from-scratch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pavanng2006-oss/machine-learning-from-scratch
- Repository: https://github.com/pavanng2006-oss/machine-learning-from-scratch

## Overview

This repository is a NumPy-based machine-learning learning project: users study standalone implementations of supervised and unsupervised algorithms, alongside separate mathematics and NumPy exercises. The typical algorithm workflow is to provide training arrays, fit a model, then request predictions or cluster/reduced-data results. The README documents the capabilities, but most algorithm sources were not sampled; their internal flow is therefore not inferred. The math and NumPy exercises are independent examples, not a shared runtime pipeline.

Main entry points: [`algorithms/supervised/random_forest_classifier.py`](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/random_forest_classifier.py) (Random forest), [`algorithms/supervised/decision_tree_classifier.py`](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/decision_tree_classifier.py) (Decision tree), [`algorithms/supervised/linear_regression_closed.py`](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/linear_regression_closed.py) (Linear regression), [`algorithms/supervised/linear_regression_gradient_descent.py`](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/linear_regression_gradient_descent.py) (Gradient descent regression)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_supervised["Supervised learning"]
  node_linear_closed["Linear regression"]
  node_linear_gd["Gradient descent regression"]
  node_logistic["Logistic regression"]
  node_knn["K-nearest neighbors"]
  node_naive_bayes["Gaussian naive Bayes"]
  node_decision_tree["Decision tree"]
  node_random_forest["Random forest"]
  node_perceptron["Perceptron<br/>[perceptron.py]"]
end

subgraph group_unsupervised["Unsupervised learning"]
  node_kmeans["K-means clustering"]
  node_pca["Principal component analysis"]
  node_dbscan["DBSCAN<br/>[DBSCAN.py]"]
end

subgraph group_foundations["Math foundations"]
  node_math_exercises["Math concepts<br/>[solution.py]"]
end

subgraph group_numpy["NumPy exercises"]
  node_numpy_exercises["NumPy operations<br/>[solution.py]"]
end

node_learner(("Learner"))

node_learner -->|"studies or runs"| node_linear_closed
node_learner -->|"studies or runs"| node_linear_gd
node_learner -->|"studies or runs"| node_logistic
node_learner -->|"studies or runs"| node_knn
node_learner -->|"studies or runs"| node_naive_bayes
node_learner -->|"studies or runs"| node_decision_tree
node_learner -->|"studies or runs"| node_random_forest
node_learner -->|"studies or runs"| node_perceptron
node_learner -->|"studies or runs"| node_kmeans
node_learner -->|"studies or runs"| node_pca
node_learner -->|"studies or runs"| node_dbscan
node_learner -->|"studies"| node_math_exercises
node_learner -->|"studies"| node_numpy_exercises
node_random_forest -->|"creates and fits"| node_decision_tree

click node_linear_closed "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/linear_regression_closed.py"
click node_linear_gd "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/linear_regression_gradient_descent.py"
click node_logistic "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/logistic_regression.py"
click node_knn "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/k_nearest_neighbours.py"
click node_naive_bayes "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/gaussian_naive_bayes.py"
click node_decision_tree "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/decision_tree_classifier.py"
click node_random_forest "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/random_forest_classifier.py"
click node_perceptron "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/perceptron.py"
click node_kmeans "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/unsupervised/k_means_clustering.py"
click node_pca "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/unsupervised/principal_component_analysis.py"
click node_dbscan "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/unsupervised/DBSCAN.py"
click node_math_exercises "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/math-vectors-matrices-tensors/solution.py"
click node_numpy_exercises "https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/numpy-matrix-multiplication/solution.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_linear_closed,node_linear_gd,node_logistic,node_knn,node_naive_bayes,node_decision_tree,node_random_forest,node_perceptron toneBlue
class node_kmeans,node_pca,node_dbscan toneAmber
class node_math_exercises toneMint
class node_numpy_exercises toneRose
class node_learner toneIndigo
```

## Components

### Supervised learning

- [Linear regression](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/linear_regression_closed.py): `algorithms/supervised/linear_regression_closed.py`
- [Gradient descent regression](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/linear_regression_gradient_descent.py): `algorithms/supervised/linear_regression_gradient_descent.py`
- [Logistic regression](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/logistic_regression.py): `algorithms/supervised/logistic_regression.py`
- [K-nearest neighbors](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/k_nearest_neighbours.py): `algorithms/supervised/k_nearest_neighbours.py`
- [Gaussian naive Bayes](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/gaussian_naive_bayes.py): `algorithms/supervised/gaussian_naive_bayes.py`
- [Decision tree](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/decision_tree_classifier.py): `algorithms/supervised/decision_tree_classifier.py`
- [Random forest](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/random_forest_classifier.py): `algorithms/supervised/random_forest_classifier.py`
- [Perceptron](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/supervised/perceptron.py): `algorithms/supervised/perceptron.py`

### Unsupervised learning

- [K-means clustering](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/unsupervised/k_means_clustering.py): `algorithms/unsupervised/k_means_clustering.py`
- [Principal component analysis](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/unsupervised/principal_component_analysis.py): `algorithms/unsupervised/principal_component_analysis.py`
- [DBSCAN](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/algorithms/unsupervised/DBSCAN.py): `algorithms/unsupervised/DBSCAN.py`

### Math foundations

- [Math concepts](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/math-vectors-matrices-tensors/solution.py): `math-vectors-matrices-tensors/solution.py`

### NumPy exercises

- [NumPy operations](https://github.com/pavanng2006-oss/machine-learning-from-scratch/blob/main/numpy-matrix-multiplication/solution.py): `numpy-matrix-multiplication/solution.py`

### Other components

- **Learner**

## Connections

- Learner → Linear regression: studies or runs (evidence: `README.md`)
- Learner → Gradient descent regression: studies or runs (evidence: `README.md`)
- Learner → Logistic regression: studies or runs (evidence: `README.md`)
- Learner → K-nearest neighbors: studies or runs (evidence: `README.md`)
- Learner → Gaussian naive Bayes: studies or runs (evidence: `README.md`)
- Learner → Decision tree: studies or runs (evidence: `README.md`)
- Learner → Random forest: studies or runs (evidence: `README.md`)
- Learner → Perceptron: studies or runs (evidence: `README.md`)
- Learner → K-means clustering: studies or runs (evidence: `README.md`)
- Learner → Principal component analysis: studies or runs (evidence: `README.md`)
- Learner → DBSCAN: studies or runs (evidence: `README.md`)
- Learner → Math concepts: studies (evidence: `README.md`)
- Learner → NumPy operations: studies (evidence: `README.md`)
- Random forest → Decision tree: creates and fits (evidence: `algorithms/supervised/random_forest_classifier.py`)
