Skip to main content

Simple ML training framework

Project description

trainedml

Modular machine learning framework for Python — train, benchmark, and visualize ML models with a unified API, CLI, and web interface.

PyPI version Python versions License: MIT Documentation Webapp Tests Coverage


Table of Contents

Matrice de corrélation Histogramme Courbe Comparaison de modèles


Overview

trainedml est un package Python modulaire pour entraîner, comparer et visualiser des modèles de machine learning sur des jeux de données classiques ou personnalisés. Il offre une API unifiée, une interface en ligne de commande et une application web interactive Streamlit pour des workflows ML complets.


Installation

pip install trainedml

Or install from source:

git clone https://github.com/diamankayero/trainedml.git
cd trainedml
pip install -e .

Requirements: Python 3.9+


Quickstart

from trainedml import Trainer

# Train on a built-in dataset
trainer = Trainer(dataset="iris", model="random_forest")
trainer.fit()

# Evaluate
scores = trainer.evaluate()
print(scores)

# Predict
predictions = trainer.predict([[5.1, 3.5, 1.4, 0.2]])
print(predictions)

Features

  • Unified API — train, evaluate, and predict with a single Trainer class
  • Built-in datasets — Iris, Wine, and any remote CSV via URL
  • Modular models — KNN, Logistic Regression, Random Forest, and more
  • Standard metrics — accuracy, precision, recall, F1, R², MSE, RMSE, MAE
  • Benchmarking — compare models side-by-side with timing and parallelization
  • Exploratory analysis — correlations, distributions, missing values, outliers, multicollinearity
  • Visualization — heatmaps, histograms, line plots, boxplots, bivariate charts
  • CLI — automate ML pipelines from the terminal
  • Streamlit webapp — interactive web interface for exploration and prediction
  • Full test coverage — 100% coverage with Sphinx documentation

API Reference

Trainer

The main entry point for the framework.

from trainedml import Trainer

trainer = Trainer(dataset="iris", model="knn")
trainer.fit()
scores = trainer.evaluate()
predictions = trainer.predict([[5.1, 3.5, 1.4, 0.2]])

Train on a custom remote dataset:

trainer = Trainer(
    url="https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv",
    target="quality",
    model="logistic"
)
trainer.fit()

DataLoader

from trainedml.data.loader import DataLoader

X, y = DataLoader().load_dataset(name="wine")

KNNModel (and other models)

from trainedml.models.knn import KNNModel

model = KNNModel(n_neighbors=3)
model.fit(X_train, y_train)
predictions = model.predict(X_test)

Benchmark

from trainedml.benchmark import Benchmark
from trainedml.models.knn import KNNModel
from trainedml.models.random_forest import RandomForestModel

models = {"knn": KNNModel(), "rf": RandomForestModel()}
bench = Benchmark(models)
results = bench.run(X_train, y_train, X_test, y_test)
print(results)

Visualizer

from trainedml.visualization import Visualizer

viz = Visualizer(X)
fig = viz.heatmap()
fig.show()

CLI Usage

# Show help
python -m trainedml --help

# Benchmark all models on Iris
python -m trainedml --benchmark --dataset iris

# Train KNN on Wine
python -m trainedml --model knn --dataset wine

# Visualize correlation heatmap
python -m trainedml --dataset iris --show

Interactive Webapp

streamlit run trainedml_webapp/src/app.py

Or visit the hosted version: trainedml.streamlit.app


Architecture

trainedml/
├── src/trainedml/
│   ├── __init__.py        # Trainer API
│   ├── analyzer.py        # Exploratory data analysis
│   ├── benchmark.py       # Model benchmarking
│   ├── cli.py             # CLI interface
│   ├── evaluation.py      # Evaluation metrics
│   ├── figure.py          # Figure generation
│   ├── visualization.py   # Visualization tools
│   ├── data/              # Data loading
│   ├── models/            # ML models (KNN, LR, RF, ...)
│   ├── utils/             # Utility functions
│   └── viz/               # Advanced visualizations
├── doc/                   # Sphinx documentation
├── tests/                 # Unit tests
├── trainedml_webapp/      # Streamlit webapp
└── requirements.txt

Testing

pytest tests/

Documentation


Contributing

Contributions are welcome!

  1. Fork the project
  2. Create your feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m 'Add my feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Open a Pull Request

For bugs or suggestions, open an issue.


License

MIT — see LICENSE for details.

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

trainedml-0.1.2.tar.gz (457.2 kB view details)

Uploaded Source

Built Distribution

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

trainedml-0.1.2-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

Details for the file trainedml-0.1.2.tar.gz.

File metadata

  • Download URL: trainedml-0.1.2.tar.gz
  • Upload date:
  • Size: 457.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for trainedml-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2f2b59d12c7810c97aec3479cead5b87d5f440bda120c89b54c43b1c61d97159
MD5 7bd0e9dfabdcdd5dacd2ab5ff5e9c034
BLAKE2b-256 98405fb72aa467848fbdb9322d6813639f8bc9f8566d87cd67d0f05fc3263cca

See more details on using hashes here.

File details

Details for the file trainedml-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: trainedml-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 50.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for trainedml-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b32d853703554f67416cf67d6c7bf39592492a9ede35adb1c9b43d455271e32d
MD5 2f76689b20f0e3ef82d930b33e9fbf2d
BLAKE2b-256 88d853148335ac7b06c0e9956397a95a70727e9f3ca575d6d295f25127f36901

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