Skip to main content

Mini machine learning library

Project description

microMlKit

microMlKit is a lightweight, educational machine learning toolkit built with NumPy and a scikit-learn-inspired API.

Package name for imports and installation metadata: micromlkit (all lowercase).

What this project is

This library is intended for learning, experimentation, and understanding ML internals—not production workloads.

It includes:

  • Estimator and mixin base classes
  • Linear models
  • Clustering, tree, ensemble, neighbors, SVM, and decomposition modules
  • Preprocessing helpers
  • Classification and regression metrics
  • Model selection helpers (train_test_split, KFold, StratifiedKFold, cross-validation, grid search)

Installation

Install from PyPI:

pip install micromlkit

Quick start

Linear regression example

import numpy as np

from micromlkit.linear_model.linear_regression import LinearRegression
from micromlkit.metrics.regression import mean_squared_error, r2_score
from micromlkit.model_selection.split import train_test_split

X = np.array([[1.0], [2.0], [3.0], [4.0], [5.0]])
y = np.array([2.0, 4.1, 6.1, 8.2, 10.1])

X_train, X_test, y_train, y_test = train_test_split(
	X, y, test_size=0.4, random_state=42
)

model = LinearRegression().fit(X_train, y_train)
predictions = model.predict(X_test)

print("MSE:", mean_squared_error(y_test, predictions))
print("R2:", r2_score(y_test, predictions))

Base pipeline example

BasePipeline (from micromlkit.base) supports a simple transform-then-estimate flow.

import numpy as np

from micromlkit.base import BasePipeline


class DoubleTransformer:
	def fit_transform(self, X, y=None):
		return np.asarray(X) * 2

	def transform(self, X):
		return np.asarray(X) * 2


class FirstColumnModel:
	def fit(self, X, y=None):
		return self

	def predict(self, X):
		X = np.asarray(X)
		return X[:, 0]


pipeline = BasePipeline(
	steps=[("double", DoubleTransformer()), ("model", FirstColumnModel())]
)

X = np.array([[1, 2], [3, 4]])
y = np.array([10, 20])

pipeline.fit(X, y)
print(pipeline.predict(X))

Module highlights

  • micromlkit.base: BaseEstimator, BaseModel, BaseTransformer, mixins, BasePipeline
  • micromlkit.linear_model: LinearRegression, Lasso, Ridge, LogisticRegression
  • micromlkit.metrics: classification + regression metrics
  • micromlkit.model_selection: splitters, cross-validation, search utilities
  • micromlkit.preprocessing: encoder, imputer, scaler helpers
  • micromlkit.cluster, tree, ensemble, neighbors, svm, decomposition

Testing

Run the test suite:

pytest

Current status

  • API is intentionally minimal and may evolve.
  • Some advanced conveniences (for example, richer nested-parameter handling and expanded pipeline ergonomics) are still limited.

Implementation checklist

Status below is based on current source files in micromlkit/.

Implemented (non-empty)

  • micromlkit/__init__.py
  • micromlkit/base.py
  • micromlkit/linear_model/linear_regression.py
  • micromlkit/linear_model/lasso.py
  • micromlkit/linear_model/ridge.py
  • micromlkit/linear_model/logistic_regression.py
  • micromlkit/linear_model/__init__.py
  • micromlkit/metrics/classification.py
  • micromlkit/metrics/regression.py
  • micromlkit/metrics/__init__.py
  • micromlkit/model_selection/split.py
  • micromlkit/model_selection/cross_validation.py
  • micromlkit/model_selection/search.py
  • micromlkit/model_selection/__init__.py
  • micromlkit/preprocessing/encoder.py
  • micromlkit/preprocessing/imputer.py
  • micromlkit/preprocessing/scaler.py
  • micromlkit/preprocessing/__init__.py
  • micromlkit/decomposition/pca.py
  • micromlkit/decomposition/__init__.py
  • micromlkit/pipeline/pipeline.py
  • micromlkit/pipeline/__init__.py

Pending implementation (empty files)

Cluster

  • micromlkit/cluster/agglomerative.py
  • micromlkit/cluster/dbscan.py
  • micromlkit/cluster/kmeans.py
  • micromlkit/cluster/__init__.py (exports)

Ensemble

  • micromlkit/ensemble/random_forest.py
  • micromlkit/ensemble/gradient_boosting.py
  • micromlkit/ensemble/__init__.py (exports)

Neighbors

  • micromlkit/neighbors/knn_classifier.py
  • micromlkit/neighbors/knn_regressor.py
  • micromlkit/neighbors/__init__.py (exports)

SVM

  • micromlkit/svm/svm.py
  • micromlkit/svm/__init__.py (exports)

Tree

  • micromlkit/tree/decision_tree_classifier.py
  • micromlkit/tree/decision_tree_regressor.py
  • micromlkit/tree/__init__.py (exports)

Utils

  • micromlkit/utils/math.py
  • micromlkit/utils/validation.py
  • micromlkit/utils/__init__.py (exports)

Project layout

micromlkit/
├── base.py
├── cluster/
├── decomposition/
├── ensemble/
├── linear_model/
├── metrics/
├── model_selection/
├── neighbors/
├── pipeline/
├── preprocessing/
├── svm/
└── tree/

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

micromlkit-0.1.4.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

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

micromlkit-0.1.4-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file micromlkit-0.1.4.tar.gz.

File metadata

  • Download URL: micromlkit-0.1.4.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for micromlkit-0.1.4.tar.gz
Algorithm Hash digest
SHA256 caaa4a35151e91e8e71e5337111af94f9b3decba97ab3bb898194dcfcf753664
MD5 faed71d8445f9f82ea61161fdaf7868f
BLAKE2b-256 288da6f86f135ac7131c98f065db7b4bc89358c1d883ce22d4c69b3eddfde25c

See more details on using hashes here.

Provenance

The following attestation bundles were made for micromlkit-0.1.4.tar.gz:

Publisher: pypi_publish.yml on COLLiDER4D/microMlKit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file micromlkit-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: micromlkit-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for micromlkit-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ab4500b2d5910c245c77542d1aa8ed26abaf03dd82ff364647b277b6240838d7
MD5 b16f3c86f506dfbc3e5a59550d75a054
BLAKE2b-256 115901a9f7453eeaf11211bb0ae8e9af093bb89378cc83af309ff7e3c5bb8459

See more details on using hashes here.

Provenance

The following attestation bundles were made for micromlkit-0.1.4-py3-none-any.whl:

Publisher: pypi_publish.yml on COLLiDER4D/microMlKit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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