Framing ML Problems and the scikit-learn API
Turning a business question into a learning task with a target, metric and baseline, and the fit/predict interface shared by scikit-learn models.
Beginner · about 5 hours · difficulty 2/5
Learn first: Train/Validation/Test Splits and Data Leakage
Before choosing an algorithm, decide what you are predicting, for whom, and how success is measured. Many failed ML projects had fine models for the wrong question.
Framing
- Task type: regression (a number), binary or multiclass classification, ranking, clustering, forecasting.
- Unit and timing: one prediction per what, made when, using which information.
- Metric tied to cost: a missed fraud case and a false alarm rarely cost the same.
- Baselines: predict the mean or majority class, or a simple rule. If ML cannot beat a heuristic, stop and rethink.
- Is ML even needed? Deterministic rules are cheaper to build and explain when they work.
The scikit-learn estimator API
Every model follows the same shape: model = SomeEstimator(**hyperparams), model.fit(X_train, y_train), then model.predict(X) or model.predict_proba(X). Transformers use fit / transform. Learned attributes end in an underscore (coef_, feature_importances_). This consistency means once you learn one model you can swap in others in one line.
Good enough to move on when you can write a one-paragraph problem statement with target, metric and baseline, and train a DummyClassifier baseline plus one real model with scikit-learn.
Key concepts
- Regression versus classification
- Choosing a metric from business cost
- Baselines and DummyEstimators
- fit, predict and predict_proba
- Transformers and fit_transform
- When not to use ML
Mini project
Write a one-page problem framing for predicting customer churn with the public Telco Customer Churn dataset, then train a majority-class baseline and a logistic regression and compare them.
Check yourself
Why should every project start with a dummy baseline before any tuned model?
Free resources
- scikit-learn: Getting started (scikit-learn)
- Google ML Crash Course (Google)
- Kaggle Learn: Intro to Machine Learning (Kaggle)