Skip to main content

A professional Python library implementing core machine learning algorithms from ML lab experiments.

Project description

ML Lab Toolkit

A production-ready Python library implementing core machine learning algorithms from ML lab experiments. Install worldwide with:

pip install ml-lab-toolkit

Installation

pip install ml-lab-toolkit

Development install:

git clone https://github.com/your-username/ml-lab-toolkit.git
cd ml-lab-toolkit
pip install -e ".[dev]"

Quick Start

from mllab import PCA, KNN, FindS, LWR
from mllab import LinearRegression, PolynomialRegression
from mllab import DecisionTree, NaiveBayes, KMeans
import numpy as np

X = np.random.randn(50, 4)
pca = PCA(n_components=2)
X_reduced = pca.fit_transform(X)

knn = KNN(n_neighbors=3)
knn.fit(X[:30], np.random.randint(0, 2, 30))
predictions = knn.predict(X[30:])

Algorithms

Module Class Description
mllab.pca PCA Principal Component Analysis
mllab.find_s FindS Find-S concept learning
mllab.knn KNN k-Nearest Neighbors classifier
mllab.lwr LWR Locally Weighted Regression
mllab.linear_regression LinearRegression Ordinary least squares regression
mllab.polynomial_regression PolynomialRegression Polynomial feature regression
mllab.decision_tree DecisionTree Entropy-based decision tree
mllab.naive_bayes NaiveBayes Gaussian Naive Bayes
mllab.kmeans KMeans K-Means clustering

Usage Examples

PCA (Experiment 3)

from mllab import PCA
import numpy as np

X = np.random.randn(150, 4)
model = PCA(n_components=2, standardize=True)
X_2d = model.fit_transform(X)
print(model.explained_variance_ratio_)

Find-S (Experiment 4)

from mllab import FindS

model = FindS(positive_label="Yes")
model.fit(X_attributes, y_labels)
print(model.hypothesis_)

KNN (Experiment 5)

from mllab import KNN

model = KNN(n_neighbors=5)
model.fit(X_train, y_train)
accuracy = model.score(X_test, y_test)

LWR (Experiment 6)

from mllab import LWR

model = LWR(tau=1.0)
model.fit(x_train, y_train)
y_pred = model.predict(x_test)

Linear & Polynomial Regression (Experiment 7)

from mllab import LinearRegression, PolynomialRegression

linear = LinearRegression().fit(X, y)
poly = PolynomialRegression(degree=3).fit(X, y)

Decision Tree (Experiment 8)

from mllab import DecisionTree

tree = DecisionTree(max_depth=7)
tree.fit(X_train, y_train)
predictions = tree.predict(X_test)

Naive Bayes (Experiment 9)

from mllab import NaiveBayes

nb = NaiveBayes().fit(X_train, y_train)
accuracy = nb.score(X_test, y_test)

K-Means (Experiment 10)

from mllab import KMeans

kmeans = KMeans(n_clusters=2, random_state=42)
labels = kmeans.fit_predict(X)

API Documentation

All estimators follow a scikit-learn-like API:

  • fit(X, y) — train the model
  • predict(X) — generate predictions
  • score(X, y) — evaluate performance (where applicable)
  • fit_transform(X) — fit and transform (PCA)
  • fit_predict(X) — fit and return labels (KMeans)

Shared utilities live in mllab.utils:

  • StandardScaler
  • as_2d_array, as_1d_array
  • euclidean_distances

Project Structure

ml-lab-toolkit/
├── src/mllab/
│   ├── pca.py
│   ├── find_s.py
│   ├── knn.py
│   ├── lwr.py
│   ├── linear_regression.py
│   ├── polynomial_regression.py
│   ├── decision_tree.py
│   ├── naive_bayes.py
│   ├── kmeans.py
│   └── utils/
├── examples/
├── tests/
├── pyproject.toml
├── requirements.txt
└── README.md

Running Tests

pytest -v

Building for PyPI

pip install build twine
python -m build
twine check dist/*

Publishing to PyPI

  1. Create accounts on PyPI and TestPyPI.
  2. Generate an API token.
  3. Build the package:
python -m build
  1. Upload to TestPyPI first:
twine upload --repository testpypi dist/*
pip install -i https://test.pypi.org/simple/ ml-lab-toolkit
  1. Upload to PyPI:
twine upload dist/*
  1. Verify installation:
pip install ml-lab-toolkit
python -c "from mllab import PCA, KNN; print('OK')"

License

MIT License. See LICENSE.

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

ml_lab_toolkit-1.0.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

ml_lab_toolkit-1.0.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file ml_lab_toolkit-1.0.0.tar.gz.

File metadata

  • Download URL: ml_lab_toolkit-1.0.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for ml_lab_toolkit-1.0.0.tar.gz
Algorithm Hash digest
SHA256 40e5b42c5c18a12b45bb91b73ee427a6a9bca4bdfed928d1d436aedb29326769
MD5 f9dd4223d94aea80540b4f6a433f2947
BLAKE2b-256 a3431a42aa098784685a1ba2e55651955612e64284e0684724dc1a4a92935e2a

See more details on using hashes here.

File details

Details for the file ml_lab_toolkit-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ml_lab_toolkit-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for ml_lab_toolkit-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5bb371abd445aa5442dd8244610ca9b14e835e0ed8ae0f642b63fdfb391469e3
MD5 2d0f6a3b5d1d74582d413ffa788c8312
BLAKE2b-256 fa70e2253bf45532328f60296b19ace1a2ae651e9adc5dcb174019c03049d2ac

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