Sub topic 2
Simple Models as Strong Baselines
Assume you know supervised learning, common evaluation metrics, train/test splits, and basic scikit-learn. A baseline is a reference result. It answers: “How much better is the candidate model than a reasonable alternative?”
Simple models as strong baselines
A simple model can be difficult to beat because it captures the main signal with little variance and few tuning decisions.
- Linear or logistic regression gives a fast, interpretable baseline.
- A shallow decision tree tests whether simple nonlinear rules help.
- A regularized model limits overfitting when features are numerous.
Use the same features, target, metric, and data splits for every model.
| Task | Strong simple baseline | Typical metric |
|---|---|---|
| Classification | Logistic regression | Balanced accuracy or F1 |
| Regression | Linear regression | MAE or RMSE |
| Forecasting | Seasonal or previous-value rule | MAE or MAPE |
Heuristics and the existing system as baselines
A heuristic is a fixed rule based on domain knowledge. Examples include assigning a risk score above a threshold or predicting tomorrow’s value as today’s value.
The current production system is also a baseline. A new model must improve the system’s real outcome, not only an offline score. Record its errors, latency, operating cost, and maintenance burden.
Repeated cross-validation for fair comparisons
Cross-validation trains and evaluates a model on several different partitions of the data. Repeated cross-validation uses new partitions repeatedly, which helps reveal score variation.
from sklearn.datasets import make_classification
from sklearn.dummy import DummyClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import RepeatedStratifiedKFold, cross_val_score
X, y = make_classification(
n_samples=2000, weights=[0.95, 0.05], random_state=0
)
cv = RepeatedStratifiedKFold(n_splits=5, n_repeats=3, random_state=0)
baseline = cross_val_score(
DummyClassifier(strategy="prior"), X, y, cv=cv,
scoring="balanced_accuracy"
)
candidate = cross_val_score(
LogisticRegression(max_iter=1000), X, y, cv=cv,
scoring="balanced_accuracy"
)
gain = candidate - baseline
print("mean gain:", gain.mean())
print("gain standard deviation:", gain.std(ddof=1))Telling a real improvement from noise
Compare paired fold scores, not unrelated runs. A rough standard error is the standard deviation of the gains divided by the square root of the number of scores. If the gain is small relative to this variation, collect more data or repeat the evaluation before deciding.
Comparing a candidate to the baseline
Define a minimum useful gain before inspecting results. Also check latency, memory, error slices, and operational cost. A candidate that wins by 0.002 balanced accuracy but doubles serving cost may not be better.
Exercise
Why must the baseline and candidate use identical cross-validation folds?
Show answer
Paired folds control for differences in sample difficulty, so the score difference reflects the models more than the split.