Metadata-Version: 2.4
Name: mlmechanica
Version: 0.1.0
Summary: A transparent, 'Glass Box' Machine Learning library designed for education.
Author-email: Sarbik Mal <sarbikjob1999@gmail.com>
License: MIT License
        
        Copyright (c) 2025 [Sarbik Mal]
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/Sarbik-Mal/mlmechanica
Keywords: machine learning,education,linear regression,transparent ai,numpy
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21.0
Requires-Dist: scipy>=1.7.0
Requires-Dist: scikit-learn>=1.0.0
Dynamic: license-file

# MLMechanica

[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)]()
[![License](https://img.shields.io/badge/license-MIT-green)]()
[![Status](https://img.shields.io/badge/status-active-success)]()

**Machine Learning, Unveiled.**

`mlmechanica` is a custom Machine Learning library built from scratch in
Python. Unlike traditional libraries that treat models as "black boxes,"
MLMechanica is designed to be a **"Glass Box"**---offering complete
transparency into the mathematical operations, internal states, and
iterative steps of every algorithm.

It is strictly educational, optimized for clarity and understanding
rather than production speed.

------------------------------------------------------------------------

## 🚀 Key Features

-   **Transparency First**: Enable the `calculation=True` flag to see
    every matrix multiplication, gradient update, and intermediate
    derivation logged to your console in real-time.
-   **Pure Python & NumPy**: Implementations rely solely on NumPy for
    linear algebra, avoiding high-level abstractions to show exactly how
    the math works.
-   **Self-Documenting Models**: Every class includes a
    `model_analysis()` method that returns the rigorous mathematical
    derivation and theory behind that specific algorithm.
-   **Instant Demos**: Built-in static `demo()` methods allow you to run
    smoke tests and visualize model performance instantly without
    writing setup code.

------------------------------------------------------------------------

## 📦 Installation

### From Source

You can clone the repository directly from GitHub:

``` bash
git clone https://github.com/Sarbik-Mal/mlmechanica.git
cd mlmechanica
pip install .
```

(Note: PyPI installation coming soon via `pip install mlmechanica`)

------------------------------------------------------------------------

## ⚡ Quick Start

### 1. Run a built-in Demo

Want to see Lasso Regression in action immediately? Every model comes
with a static demo that generates synthetic data, trains the model, and
evaluates it.

``` python
from mlmechanica.regression.linear import LassoRegression


LassoRegression.demo()
```

### 2. Custom Usage with "Calculation Mode"

See the internal math (Gradient Descent, Matrix Inversion, etc.) by
setting `calculation=True`.

``` python
import numpy as np
from mlmechanica.regression.linear import MultipleLinearRegression

X = np.array([[1, 2], [2, 3], [3, 4], [4, 5]])
y = np.array([2, 3, 4, 5])

model = MultipleLinearRegression(calculation=True)

model.fit(X, y)

pred = model.predict(np.array([[5, 6]]))
print(f"Prediction: {pred}")
```

------------------------------------------------------------------------

## 📚 Supported Models

Currently, the library focuses on linear regression techniques:

| Module | Class | Description |
| :--- | :--- | :--- |
| **Simple Linear** | `SimpleLinearRegression` | Univariate regression using closed-form OLS derivation. |
| **Multiple Linear** | `MultipleLinearRegression` | Multivariate regression using the Normal Equation (Vectorized). |
| **Lasso** | `LassoRegression` | L1 Regularization using Coordinate Descent and Soft Thresholding. |
| **Ridge** | `RidgeRegression` | L2 Regularization offering multiple solvers: `lsqr`, `svd`, `cholesky`, and `mbsag` (Stochastic Avg Gradient). |

## 🧠 Model Analysis

Retrieve the mathematical derivation directly from any model:

``` python
from mlmechanica.regression.linear import SimpleLinearRegression

model = SimpleLinearRegression()

print(model.model_analysis('derivation'))
```

------------------------------------------------------------------------

## 🤝 Contributing

Contributions are welcome! This is an educational project, so clarity
and readability are prioritized.

1.  Fork the Project\
2.  Create a Feature Branch (`git checkout -b feature/NewAlgorithm`)\
3.  Commit Changes (`git commit -m 'Add DecisionTree implementation'`)\
4.  Push to Branch (`git push origin feature/NewAlgorithm`)\
5.  Open a Pull Request

------------------------------------------------------------------------

## 📄 License

Distributed under the MIT License. See `LICENSE` for more information.
