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.1.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.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ml_lab_toolkit-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 3378c5440bc5dccc19f26db263f1ec928c310b975a776240b73070c3fe79da27
MD5 09872ca66e6a5967705eef4da044a31a
BLAKE2b-256 424201bc3c19f57e70a0a045ecd42319a2dec0c69c6124a2878d91e310e9cad0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ml_lab_toolkit-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c39b7bf98f98bb638e9183f4b4b309b53234709a45bd008ee141ebcf79502a45
MD5 0313bf5757fa412ff509370a2e877443
BLAKE2b-256 0d58112c657df25d6217048afd5c87d7d84c8a336fec327478fd108c45e7b668

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