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.2.tar.gz (15.2 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.2-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ml_lab_toolkit-1.0.2.tar.gz
  • Upload date:
  • Size: 15.2 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.2.tar.gz
Algorithm Hash digest
SHA256 335d639236ca96141d0631d0936239cb4cd9199c309e3aadd2666dcb8bb4b926
MD5 2d2ac03c1f232224555327ddfbbc802c
BLAKE2b-256 ab14b7b4f763d48c839a3138a06cb80601f42df5e73b42787ca4409899697748

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ml_lab_toolkit-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 20.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a97158d75992d96ff7e911509e1fee95297c7062c8945054b652417cfa1a3f07
MD5 52bdc81380969b5b86f3a4ae73a61dfc
BLAKE2b-256 97e44b214f2d6568cf98e03fbba915624ddf83be7b0ddd10e69adc4ea714b35b

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