RegressionMadeSimple
A minimalist machine learning toolkit on top of scikit-learn.
v4.0.0 - Latest Release🎉 What's New in v4.0.0
- Class-based model selection is now required in wrapper/function APIs.
- String model names removed (for example,
model="linear"is no longer valid). - Model registry API available via
rms.models.Linear,Quadratic, andCubic. - Built-in metrics and serialization with
summary(),r2_score(),mae(),rmse(),save_model(), andload_model().
Quick Start
pip install regressionmadesimple
import regressionmadesimple as rms
import pandas as pd
# Load data
data = pd.DataFrame({
"x": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"y": [2.1, 4.2, 6.1, 8.3, 10.2, 12.1, 14.3, 16.2, 18.1, 20.3]
})
# Recommended API
model = rms.models.Linear(data, "x", "y")
# Predictions
predictions = model.predict([[11], [12]])
# Metrics
summary = model.summary()
print(summary["r2_score"])
print(summary["rmse"])
# Save model
model.save_model("my_model.pkl")
Wrapper API (v4)
model = rms.LinearRegressionModel.fit(
data,
"x",
"y",
model=rms.models.Quadratic,
testsize=0.2
)
Function API (v4)
from regressionmadesimple.api import fit
import numpy as np
X = np.array([[1], [2], [3], [4], [5]], dtype=float)
y = np.array([2.1, 4.0, 6.2, 7.9, 10.1], dtype=float)
model, results = fit(
X,
y,
model=rms.models.Linear,
split_ratio=[8, 2],
random_state=42,
)
print(results["r2_score"])
Key Features
🎯 Simple API
Thin wrapper around scikit-learn designed for quick experiments and learning.
📊 Multiple Models
Linear, quadratic, cubic, and custom curve support.
💾 Model Persistence
Persist fitted models with joblib-based save/load helpers.
📈 Rich Metrics
Evaluate with MSE, RMSE, MAE, and R².