# regmi-saugat/ml_algorithms architecture

> Architecture diagram of the GitHub repository regmi-saugat/ml_algorithms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/regmi-saugat/ml_algorithms
- Repository: https://github.com/regmi-saugat/ml_algorithms

## Overview

##### Project type and purpose
- This is an open-source Python library of classic Machine Learning algorithms implemented from scratch.
- Its purpose is educational: to demonstrate algorithm internals (Linear Regression, Logistic Regression, Naive Bayes, Perceptron, SVM) and provide test harnesses.

##### File structure
- Top-level:
- README.md (entry point describing all modules).
- Directories for each algorithm:
– Linear Regression/
- linear_regression.py (core implementation)
- linear_regression_tests.py (unit tests)
- README.md (algorithm-specific doc)
– Logistic Regression/ (same structure)
– Naive Bayes/
– Perceptron/ (no README but has perceptron.py)
– SVM/ (contains Support Vector Machine script)
- __pycache__ folders under each (build artifacts).
- No external services, no separate frontend/backend—pure library.

##### README for additional insights
- Lists each algorithm as a link, reaffirming that each directory is a self-contained module with its own docs and tests.
- No special instructions on architecture; it's a flat, modular directory per algorithm.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Data Input
    DataInput["Data Input (CSV / NumPy)"]:::data

    %% Documentation
    RootDocumentation["Root README"]:::docs
    LinearRegressionDocs["Linear Regression README"]:::docs
    LogisticRegressionDocs["Logistic Regression README"]:::docs
    NaiveBayesDocs["Naive Bayes README"]:::docs

    %% Algorithm Modules
    LinearRegressionModule["Linear Regression Module"]:::algo
    LogisticRegressionModule["Logistic Regression Module"]:::algo
    NaiveBayesModule["Naive Bayes Module"]:::algo
    PerceptronModule["Perceptron Module"]:::algo
    SVMModule["SVM Module"]:::algo

    %% Test Suites
    LinearRegressionTests["Linear Regression Tests"]:::tests
    LogisticRegressionTests["Logistic Regression Tests"]:::tests
    NaiveBayesTests["Naive Bayes Tests"]:::tests
    PerceptronTests["Perceptron Tests"]:::tests
    SVMTests["SVM Tests"]:::tests

    %% Model Output
    ModelOutput["Model Output (Predictions / Coefficients)"]:::output

    %% Data flow to modules
    DataInput -->|feeds| LinearRegressionModule
    DataInput -->|feeds| LogisticRegressionModule
    DataInput -->|feeds| NaiveBayesModule
    DataInput -->|feeds| PerceptronModule
    DataInput -->|feeds| SVMModule

    %% Modules to output
    LinearRegressionModule -->|produces| ModelOutput
    LogisticRegressionModule -->|produces| ModelOutput
    NaiveBayesModule -->|produces| ModelOutput
    PerceptronModule -->|produces| ModelOutput
    SVMModule -->|produces| ModelOutput

    %% Tests validate modules
    LinearRegressionTests -->|tests| LinearRegressionModule
    LogisticRegressionTests -->|tests| LogisticRegressionModule
    NaiveBayesTests -->|tests| NaiveBayesModule
    PerceptronTests -->|tests| PerceptronModule
    SVMTests -->|tests| SVMModule

    %% Documentation links
    RootDocumentation --> LinearRegressionModule
    RootDocumentation --> LogisticRegressionModule
    RootDocumentation --> NaiveBayesModule
    RootDocumentation --> PerceptronModule
    RootDocumentation --> SVMModule

    LinearRegressionDocs --> LinearRegressionModule
    LogisticRegressionDocs --> LogisticRegressionModule
    NaiveBayesDocs --> NaiveBayesModule

    RootDocumentation --> LinearRegressionTests
    RootDocumentation --> LogisticRegressionTests
    RootDocumentation --> NaiveBayesTests
    RootDocumentation --> PerceptronTests
    RootDocumentation --> SVMTests

    %% Click Events
    click LinearRegressionModule "https://github.com/regmi-saugat/ml_algorithms/blob/main/Linear Regression/linear_regression.py"
    click LinearRegressionTests "https://github.com/regmi-saugat/ml_algorithms/blob/main/Linear Regression/linear_regression_tests.py"
    click LinearRegressionDocs "https://github.com/regmi-saugat/ml_algorithms/blob/main/Linear Regression/README.md"
    click LogisticRegressionModule "https://github.com/regmi-saugat/ml_algorithms/blob/main/Logistic Regression/logistic_regression.py"
    click LogisticRegressionTests "https://github.com/regmi-saugat/ml_algorithms/blob/main/Logistic Regression/logistic_regression_test.py"
    click LogisticRegressionDocs "https://github.com/regmi-saugat/ml_algorithms/blob/main/Logistic Regression/README.md"
    click NaiveBayesModule "https://github.com/regmi-saugat/ml_algorithms/blob/main/Naive Bayes/nb.py"
    click NaiveBayesTests "https://github.com/regmi-saugat/ml_algorithms/blob/main/Naive Bayes/nb.tests.py"
    click NaiveBayesDocs "https://github.com/regmi-saugat/ml_algorithms/blob/main/Naive Bayes/README.md"
    click PerceptronModule "https://github.com/regmi-saugat/ml_algorithms/blob/main/Perceptron/perceptron.py"
    click SVMModule "https://github.com/regmi-saugat/ml_algorithms/tree/main/SVM/Support Vector Machine"
    click RootDocumentation "https://github.com/regmi-saugat/ml_algorithms/blob/main/README.md"

    %% Styles
    classDef algo fill:#add8e6,stroke:#000,stroke-width:1px
    classDef tests fill:#90ee90,stroke:#000,stroke-width:1px
    classDef data fill:#ffa500,stroke:#000,stroke-width:1px
    classDef docs fill:#d3d3d3,stroke:#000,stroke-width:1px
    classDef output fill:#ffdead,stroke:#000,stroke-width:1px
```
