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.4.tar.gz (455.8 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.4-py3-none-any.whl (49.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for trainedml-0.1.4.tar.gz
Algorithm Hash digest
SHA256 05adb7a52ba2777c2fe2335d2be5babdea10ce26d2c5424c83ca91c8450d67dd
MD5 e076dd07da2edfb311fdd4b493228030
BLAKE2b-256 4413b750eb64ec45b7e86beb6d9af9442485a5c8c2f0858dd43066d8ce91c3be

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for trainedml-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e88a7ca7c539d5f75435c058888472f3debe37ef45999d98c706d862e54efd5c
MD5 6ea80e328917d7446eb67a19457eb027
BLAKE2b-256 7db86c9b1e7e4c3e62c84e6298fd94d5d83325284fb1b274229c03d312706d46

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