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==0.1.0

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/__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

Pending implementation (empty files)

Cluster

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

Decomposition

  • micromlkit/decomposition/pca.py
  • micromlkit/decomposition/__init__.py (exports)

Ensemble

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

Linear model

  • micromlkit/linear_model/lasso.py
  • micromlkit/linear_model/ridge.py
  • micromlkit/linear_model/logistic_regression.py

Neighbors

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

Pipeline

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

Preprocessing

  • micromlkit/preprocessing/encoder.py
  • micromlkit/preprocessing/imputer.py
  • micromlkit/preprocessing/scaler.py
  • micromlkit/preprocessing/__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)

Model selection package init

  • micromlkit/model_selection/__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.1.tar.gz (17.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.1-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: micromlkit-0.1.1.tar.gz
  • Upload date:
  • Size: 17.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.1.tar.gz
Algorithm Hash digest
SHA256 ec5deec212d28689dd2c4e3d1e797adea1c33b755d218caa302f377d8f2c0f43
MD5 4b187cfb2881d81da1ddaaf251cb0744
BLAKE2b-256 d96d84d1e2caae28ce142a30fa32a05244347fadf93fee6658f817b797263c87

See more details on using hashes here.

Provenance

The following attestation bundles were made for micromlkit-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: micromlkit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 768a725aa6101aa4829302055d434f788c607c121bc8afd25433ef740fd42dee
MD5 3a8f08756b856cae631956d2e4498f5f
BLAKE2b-256 5b8bd139b6d91caedcafd64b5fc380a354fc05b74006e18ae694788c7c9d1535

See more details on using hashes here.

Provenance

The following attestation bundles were made for micromlkit-0.1.1-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