Skip to main content

Pythonic machine learning algorithms built for educational transparency and scikit-learn compatibility

Project description

simple-sklearn

CI/CD codecov PyPI version Python 3.10+ Docs License: MIT

simple-sklearn is a Python package designed to provide clear, readable, and highly pythonic implementations of fundamental machine learning algorithms. Abstracting away from complex low-level optimizations, this library focuses on clarity and educational value using high-level libraries like numpy, pandas, and scipy.

Every model is designed to integrate seamlessly with scikit-learn's estimator API, inheriting from sklearn.base.BaseEstimator and the appropriate mixins (ClassifierMixin or ClusterMixin). This allows you to plug these simple implementations directly into scikit-learn pipelines and cross-validation workflows.

WARNING: Not for Production Use. This library is built for educational purposes and algorithmic transparency. The implementations prioritize readability and simplicity over execution speed and memory optimization.


Available Models

Classification:

  • OneRClassifier: 1R (One Rule) classification.
  • NaiveBayesClassifier: Categorical Naive Bayes classification.
  • KNeighborsClassifier: K-Nearest Neighbors classification.
  • DecisionTreeClassifier: Decision Tree classification using the ID3 algorithm.

Clustering:

  • KMeans: K-Means clustering.
  • KMedoids: K-Medoids clustering.
  • DBSCAN: Density-Based Spatial Clustering of Applications with Noise.
  • AgglomerativeClustering: Hierarchical agglomerative clustering.

Installation

Requirements:

  • Python 3.10+

Install directly from PyPI using pip:

pip install simple-sklearn

Core Dependencies:

  • scikit-learn (>= 1.6.1)
  • numpy (>= 1.26)
  • pandas (>= 2.2.3)
  • scipy (>= 1.13.1)
  • typing-extensions (>=4.1.0, <5.0)

Quick Start

Because simple-sklearn strictly implements the scikit-learn API, you can fit and predict models exactly as you would with scikit-learn.

Classification Example

import numpy as np
from simple_sklearn.classification import NaiveBayesClassifier

# Categorical data
X = np.array([[0, 0], [0, 1], [1, 0], [2, 2], [2, 3]])
y = np.array([0, 0, 0, 1, 1])

# Initialize and fit the model
clf = NaiveBayesClassifier()
clf.fit(X, y)

# Predict on new data
X_new = np.array([[2, 2], [1, 4]])
predictions = clf.predict(X_new)  # Handles unseen category '4' gracefully
print(f"Predictions: {predictions}")  # Output: [1 0]

Clustering Example

import numpy as np
from simple_sklearn.clustering import KMeans

# Continuous data
X = np.array([[0.1, 0.1], [0.2, 0.1], [10.1, 10.1], [10.2, 10.1]])

# Initialize and fit the model
clusterer = KMeans(n_clusters=2, max_iter=10, random_state=42)
clusterer.fit(X)

print(f"Cluster labels: {clusterer.labels_}")  # Output: [0 0 1 1]
print(f"Cluster centers: \n{clusterer.cluster_centers_}")  # Output: [[0.15, 0.1], [10.15, 10.1]]

Documentation

Detailed API references, algorithm details, and Jupyter Notebook usage examples are available on the library website:

Artem259.github.io/simple-sklearn


Development & Contributing

Pull requests are welcome! If you'd like to contribute, please read the Contributing Guide.


Roadmap

Future development focuses on:

  1. Estimator Enhancements and Performance Optimization:
    • Implementing a custom KDTree for faster nearest-neighbor searches.
    • Refactoring AgglomerativeClustering with Priority Queue (Min-Heap) to reduce time complexity during cluster merging.
    • Adding other estimator features (e.g., standard hyperparameters like max_depth for DecisionTreeClassifier).
  2. Documentation Upgrades:
    • Configuring documentation versioning via the mike tool.

License

This project is licensed under the MIT 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

simple_sklearn-0.1.0.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

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

simple_sklearn-0.1.0-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file simple_sklearn-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for simple_sklearn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8f4ff618a5b1b9f03dcb56ddbebdd7954dfa3350280e52d30deca0e35320d1a7
MD5 11cf02e9de56399f438b40de4f64f136
BLAKE2b-256 3bdf5dc92d86df4b679a0bcab2ec6a9f1ea47474a16cd3d49bfeee0ed6fbc13a

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_sklearn-0.1.0.tar.gz:

Publisher: ci-cd.yml on Artem259/simple-sklearn

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

File details

Details for the file simple_sklearn-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for simple_sklearn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e102e094bcfa431c7b3cebbac189ea211e25ab21fc31255b8d73dd4408726bf
MD5 8b4c227e11dee798a57a237eb390b01e
BLAKE2b-256 3cfc95fc7d6a67e7bccf31cba118fb9968b57a2b9ee94a34aeae4d53605903fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_sklearn-0.1.0-py3-none-any.whl:

Publisher: ci-cd.yml on Artem259/simple-sklearn

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