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 modelpredict(X)— generate predictionsscore(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:
StandardScaleras_2d_array,as_1d_arrayeuclidean_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
python -m build
- Upload to TestPyPI first:
twine upload --repository testpypi dist/*
pip install -i https://test.pypi.org/simple/ ml-lab-toolkit
- Upload to PyPI:
twine upload dist/*
- Verify installation:
pip install ml-lab-toolkit
python -c "from mllab import PCA, KNN; print('OK')"
License
MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
335d639236ca96141d0631d0936239cb4cd9199c309e3aadd2666dcb8bb4b926
|
|
| MD5 |
2d2ac03c1f232224555327ddfbbc802c
|
|
| BLAKE2b-256 |
ab14b7b4f763d48c839a3138a06cb80601f42df5e73b42787ca4409899697748
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a97158d75992d96ff7e911509e1fee95297c7062c8945054b652417cfa1a3f07
|
|
| MD5 |
52bdc81380969b5b86f3a4ae73a61dfc
|
|
| BLAKE2b-256 |
97e44b214f2d6568cf98e03fbba915624ddf83be7b0ddd10e69adc4ea714b35b
|