Welcome to RegressionMadeSimple v3.0.0! This guide will help you upgrade from v2.x to take advantage of the new features and improvements.
Models are now accessible through a dedicated models module:
rms.models.Linear - Linear regressionrms.models.Quadratic - Quadratic regressionrms.models.Cubic - Cubic regressionrms.models.CustomCurve - Custom curve fittingAll models now inherit from an enhanced BaseModel that provides:
save_model() and load_model() methodsr2_score(), mae(), rmse()The new recommended way to specify models uses class references instead of strings.
import regressionmadesimple as rms
# Direct instantiation
model = rms.Linear(data, 'x', 'y')
# Using wrapper with string
model = rms.LinearRegressionModel.fit(
data, 'x', 'y',
model='linear'
)
import regressionmadesimple as rms
# Direct instantiation (still works!)
model = rms.Linear(data, 'x', 'y')
# Or use model registry (recommended)
model = rms.models.Linear(data, 'x', 'y')
# Using wrapper with class
model = rms.LinearRegressionModel.fit(
data, 'x', 'y',
model=rms.models.Linear
)
# String-based model selection
models = ['linear', 'quadratic', 'cubic']
for model_name in models:
model = rms.LinearRegressionModel.fit(
data, 'x', 'y',
model=model_name
)
# Class-based model selection
models = [
rms.models.Linear,
rms.models.Quadratic,
rms.models.Cubic
]
for model_class in models:
model = rms.LinearRegressionModel.fit(
data, 'x', 'y',
model=model_class
)
import regressionmadesimple as rms
# Train and save model
model = rms.models.Linear(data, 'x', 'y')
model.save_model('my_model.pkl')
# Load model later
from regressionmadesimple.models import BaseModel
loaded_model = BaseModel.load_model('my_model.pkl')
# Use loaded model
predictions = loaded_model.predict(new_data)
# Get comprehensive model evaluation
summary = model.summary()
print(f"R² Score: {summary['r2_score']:.4f}")
print(f"RMSE: {summary['rmse']:.4f}")
print(f"MAE: {summary['mae']:.4f}")
# Or access metrics directly
print(f"R² Score: {model.r2_score()}")
print(f"Mean Absolute Error: {model.mae()}")
print(f"Root Mean Squared Error: {model.rmse()}")
String-based model specification is deprecated and will be removed in v4.0.0.
If you use model='linear', you'll see a deprecation warning. Update to model=rms.models.Linear to silence the warning and future-proof your code.
No other breaking changes! All existing functionality from v2.x continues to work in v3.0.0.
import regressionmadesimple as rms
import pandas as pd
# Load data
data = pd.read_csv('data.csv')
# Fit model using string
model = rms.LinearRegressionModel.fit(
data, 'x', 'y',
model='quadratic',
testsize=0.2
)
# Make predictions
predictions = model.predict(new_data)
# Get basic metrics
summary = model.summary()
print(f"MSE: {summary['mse']}")
import regressionmadesimple as rms
import pandas as pd
# Load data
data = pd.read_csv('data.csv')
# Fit model using class (new recommended way)
model = rms.LinearRegressionModel.fit(
data, 'x', 'y',
model=rms.models.Quadratic, # ✅ Class-based
testsize=0.2
)
# Make predictions
predictions = model.predict(new_data)
# Get comprehensive metrics (new in v3.0.0!)
summary = model.summary()
print(f"MSE: {summary['mse']}")
print(f"R² Score: {summary['r2_score']:.4f}") # ✨ NEW
print(f"RMSE: {summary['rmse']:.4f}") # ✨ NEW
print(f"MAE: {summary['mae']:.4f}") # ✨ NEW
# Save model for later use (new in v3.0.0!)
model.save_model('quadratic_model.pkl') # ✨ NEW
rms.models.* for new projectsmodel='linear') with class-based (model=rms.models.Linear)save_model() and load_model() for model persistencer2_score(), mae(), rmse() for better evaluationIf you encounter any issues during migration:
Congratulations on upgrading to v3.0.0! Enjoy the new features and improved architecture.
Don't forget to check out the full changelog for all the details.