Skip to main content

A custom machine learning library implemented from scratch.

Project description

AlgoMake

AlgoMake is a powerful Machine Learning library designed for deep understanding, with every algorithm meticulously built from scratch using pure NumPy. Explore the core mechanics of ML without abstraction.


Overview

AlgoMake offers a unique approach to learning and implementing machine learning. It's a comprehensive collection of fundamental algorithms, each developed from first principles with a strong emphasis on clarity and mathematical accuracy, relying solely on NumPy.

This project serves as an invaluable resource for anyone looking to gain a transparent and educational understanding of machine learning models.


Why Choose AlgoMake?

In a landscape dominated by high-level ML frameworks, AlgoMake stands out by providing:

  • Unparalleled Transparency: Every algorithm's core logic is exposed, allowing users to see exactly how computations are performed.
  • Pure NumPy Implementation: Eliminates external dependencies for core algorithm computations, making the underlying mathematics explicit.
  • Enhanced Learning: Ideal for students and practitioners who want to master the mathematical foundations and inner workings of ML models.

Key Features

AlgoMake currently includes a growing suite of carefully engineered algorithms:

Core Algorithms (algomake/models/)

  • Gaussian Mixture Models (GMM):

    • Complete Expectation-Maximization (EM) algorithm from scratch
    • Custom implementation of the multivariate Gaussian PDF
    • Robust handling of numerical stability
  • Support Vector Machines (SVM):

    • Planned: Dual formulation, Hinge loss, Kernel trick, SMO algorithm
  • Other Models:

    • Linear Regression, Logistic Regression
    • K-Nearest Neighbors (KNN)
    • Decision Trees
    • Ensemble Methods (Bagging, Boosting)
    • Clustering Algorithms (K-Means)

Preprocessing & Dimensionality Reduction (algomake/preprocessing/)

  • Principal Component Analysis (PCA):

    • Manual computation of eigenvectors and eigenvalues
    • Covariance matrix and dimensionality reduction pipeline
  • Standardization/Normalization

Utility Components

  • BaseEstimator: A foundational class providing a consistent fit, predict, get_params, and set_params interface.
  • Metrics: Custom implementations of classification and regression evaluation metrics.

Installation

To integrate AlgoMake into your Python environment:

git clone https://github.com/ShutterStack/AlgoMake.git
cd algomake
pip install -e .

For development (includes testing, formatting, etc.):

pip install -e .[dev]

Usage Examples

Gaussian Mixture Models (GMM)

import numpy as np
from algomake.models.gmm import GaussianMixture

# Generate sample data
np.random.seed(0)
data_1 = np.random.multivariate_normal([2.0, 2.0], [[0.5, 0.2], [0.2, 0.5]], 100)
data_2 = np.random.multivariate_normal([8.0, 8.0], [[0.7, -0.3], [-0.3, 0.7]], 100)
X_train = np.vstack((data_1, data_2))

gmm = GaussianMixture(n_components=2, random_state=42, max_iter=100, tol=1e-4)
gmm.fit(X_train)

X_new = np.array([[2.1, 1.9], [8.3, 7.8], [5.0, 5.0]])
predicted_labels = gmm.predict(X_new)
probabilities = gmm.predict_proba(X_new)

print("Labels:", predicted_labels)
print("Probabilities:", np.round(probabilities, 4))

Principal Component Analysis (PCA)

import numpy as np
from algomake.preprocessing.dimensionality_reduction import PCA

X = np.array([
    [2.5, 2.4], [0.5, 0.7], [2.2, 2.9],
    [1.9, 2.2], [3.1, 3.0], [2.3, 2.7],
    [2.0, 1.6], [1.0, 1.1], [1.5, 1.6], [1.1, 0.9]
])

pca = PCA(n_components=1)
pca.fit(X)
X_transformed = pca.transform(X)

print("Transformed Data:", np.round(X_transformed, 3))

Running Tests

Run all unit tests using pytest:

pytest

Contributing

We welcome and encourage contributions! 🚀

To contribute:

  1. Fork the repository
  2. Clone your fork:
    git clone https://github.com/ShutterStack/AlgoMake.git
    
  3. Create a feature branch:
    git checkout -b feature/your-feature-name
    
  4. Implement changes
  5. Add unit tests
  6. Run pytest to ensure all tests pass
  7. Format with black and isort
  8. Commit and push your changes
  9. Open a Pull Request

License

This project is licensed under the MIT License.


Contact

Have questions, suggestions, or want to collaborate?


Enjoy learning ML from the inside out with AlgoMake!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

algomake-0.1.3.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

algomake-0.1.3-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file algomake-0.1.3.tar.gz.

File metadata

  • Download URL: algomake-0.1.3.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for algomake-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1e1be1d1a17b8d36eee2cda0140b9c50dd01958c635b2e0115a915ee6f446668
MD5 d415f52dfcffa6c1ba88d9379b5b3701
BLAKE2b-256 06d4e4a283e1be363a5686f65ec2352338981a733a13b4043c89b0600624c8ff

See more details on using hashes here.

File details

Details for the file algomake-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: algomake-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for algomake-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9a32326c14d560fa603d49e7a965f8fb7b501bb2b869b7f61e2b26c6942c4a8c
MD5 16f7e547975b813826b50a3e4afd40ed
BLAKE2b-256 983071e501c1cecedfe1284f491af6bc5f5131c4842b9175fc739f5346b85ea8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page