Skip to main content

Classic Machine Learning Framework

A dynamic, leakage-safe, production-oriented classic ML experimentation framework built primarily on scikit-learn.

It behaves like a lightweight AutoML / ML experiment runner for tabular data:

  • Automatically inspects data
  • Detects problem type (binary / multiclass classification, regression)
  • Detects feature types (numeric, categorical, boolean, datetime, ID-like, text-like, constant, high-missingness)
  • Builds reasoned preprocessing pipelines
  • Runs staged model selection (baseline → candidates → shortlist → tune)
  • Evaluates on a held-out test set once
  • Produces error analysis, feature importance, and a full experiment report

Design priorities: correctness, no data leakage, reproducibility, strong baselines, explainable decisions, maintainability, extensibility.


Architecture

ml_framework/
├── main.py                 # CLI orchestration
├── configs/default.yaml
├── src/
│   ├── data/               # load, validate, profile, split
│   ├── detection/          # problem type, feature types, target, decision engine
│   ├── preprocessing/      # ColumnTransformer pipelines
│   ├── features/           # engineering / selection hooks
│   ├── models/             # extensible registry
│   ├── training/           # baseline, CV, tuning, final train
│   ├── evaluation/         # metrics, test eval, error analysis
│   ├── explainability/     # permutation (+ optional SHAP)
│   ├── experiments/        # runner + reporter
│   ├── persistence/        # joblib full-pipeline save/load
│   └── utils/              # logging, config, seeds
├── artifacts/              # models, reports, plots
└── tests/

Every major automatic choice is logged as:

Field Meaning
Decision What was chosen
Reason Why
Action Concrete effect
Confidence high / medium / low

Installation

cd ml_framework
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt

Python 3.11+ recommended.


Quick start

# Classification or regression — framework detects automatically
python main.py --data path/to/train.csv --target my_target

# Explicit problem type
python main.py --data train.csv --target SalePrice --problem-type regression

# External test set (Kaggle-style)
python main.py --train train.csv --test test.csv --target SalePrice

# Config file
python main.py --config configs/default.yaml --data train.csv --target y

# Disable tuning for a fast run
python main.py --data train.csv --target y --no-tuning

Predict

python main.py predict \
  --model artifacts/models/best_model.joblib \
  --data new_data.csv \
  --output predictions.csv

Profile only

python main.py profile --data train.csv --target y

Configuration

See configs/default.yaml. Important knobs:

  • problem.type: auto | binary_classification | multiclass_classification | regression
  • split.test_size, random_state
  • preprocessing.high_cardinality_threshold, missing_threshold
  • models.include / exclude
  • tuning.enabled, method (randomized_search | grid_search), n_iter, shortlist_size
  • evaluation.primary_metric: auto or sklearn scorer name / friendly alias (rmse, f1, roc_auc, …)
  • explainability.enabled

CLI flags override YAML.


Supported problems & models

Problems: binary classification, multiclass classification, regression.

Models (registry): LogisticRegression, RidgeClassifier, DecisionTree, RandomForest, ExtraTrees, HistGradientBoosting, GradientBoosting, SVC, KNeighbors (classification); LinearRegression, Ridge, Lasso, ElasticNet, DecisionTree, RandomForest, ExtraTrees, HistGradientBoosting, GradientBoosting, SVR, KNeighbors (regression).

The Decision Engine selects a small candidate set based on dataset size and feature mix — it does not brute-force every model.


How leakage is prevented

  1. Train/test split happens before any fit.
  2. All imputation, scaling, encoding live inside an sklearn Pipeline + ColumnTransformer.
  3. CV and tuning operate on the full pipeline (preprocess + model).
  4. Final metrics are computed once on the untouched test set.
  5. Model selection uses CV scores, never test scores.
  6. External test sets are never used during training or tuning.

Extensibility

Add a model

from src.models.registry import register_model
from sklearn.ensemble import AdaBoostClassifier

register_model(
    "AdaBoostClassifier",
    AdaBoostClassifier,
    problem_types=["binary_classification", "multiclass_classification"],
    default_params={"random_state": 42},
    search_space={"n_estimators": [50, 100, 200]},
)

Add a data loader

from src.data.loader import register_loader

@register_loader("feather")
def load_feather(path):
    import pandas as pd
    return pd.read_feather(path)

Custom metric

Pass --metric my_scorer if registered with sklearn, or set evaluation.primary_metric in YAML.


Output structure

artifacts/
├── models/best_model.joblib    # full pipeline
├── reports/
│   ├── final_report.json
│   └── final_report.html
└── plots/
    ├── target_distribution.png
    ├── missing_heatmap.png
    ├── correlation_heatmap.png
    └── residuals.png           # regression

Example summary output

============================================================
ML EXPERIMENT COMPLETE
============================================================

Problem: Regression
Dataset: 1460 rows × 81 columns
Train: 1168 rows
Test: 292 rows
Primary Metric: RMSE
Baseline: -0.42
Best Model: HistGradientBoostingRegressor
CV: -0.251 ± 0.009
Test rmse: 0.237
Test mae: 0.164
Test r2: 0.891
Model saved: artifacts/models/best_model.joblib
Report: artifacts/reports/final_report.html
============================================================

Limitations

  • Classic tabular ML only (no deep learning, no raw text/image models).
  • Text-like columns are detected and dropped with a clear message.
  • Very high-cardinality categoricals use OrdinalEncoder (not target encoding) to avoid leakage.
  • Bayesian optimization / SHAP are optional extras.
  • Not a guarantee of the globally optimal model — it aims for strong, reproducible baselines with transparent decisions.

Tests

cd ml_framework
pytest tests/ -q

License

MIT-style — use freely in research and production prototypes.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ml_experiment_framework-0.1.0.tar.gz (45.4 kB view details)

Uploaded Source

Built Distribution

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

ml_experiment_framework-0.1.0-py3-none-any.whl (54.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ml_experiment_framework-0.1.0.tar.gz
  • Upload date:
  • Size: 45.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.9

File hashes

Hashes for ml_experiment_framework-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a64aa4e4a762876fa0a490673f308be239a96c74a98c8de0c22bdaabbacf2f25
MD5 d1a142fe6abd8febcb4a83a94d9d8b37
BLAKE2b-256 0318b8465309c4ba68492baa916d6aea8b2af61baee3e5ae18c4b71e6675e319

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ml_experiment_framework-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c66bc539a2ffd5ad987f693cd33425aac039b5ab831f6030597e98a7d8f220d7
MD5 8b8ac7941c5f048c7edb08587efc482b
BLAKE2b-256 6ffdc2ad07b785ac3f6ffdd038c00de721bdfa24cba9b23697d7591b2dbc201d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page