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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for trainedml-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5afe0bfef97142d8f772774dc1b86df81158256de4ab5748c49b379a29393b0e
MD5 5f762f3e6e2d90ac65a1a49621307c44
BLAKE2b-256 88359584abee484708dc4c6168f92bd4250777c6b334f67e83fc44d6af196f22

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trainedml-0.1.3-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.14

File hashes

Hashes for trainedml-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ddb690717e24946b3b6bfd3ee78319e6bbbc16cacce24b3749d204e401d334a9
MD5 81b98bfc671c0d95eb5ac9e950845dc0
BLAKE2b-256 d2b8be1808846be38647bc7e5694cc4dd8c239c94f2b4ce28c60630b12de0a7f

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