# 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. Free notes,...

Canonical: https://www.internhack.in/roadmaps/tracks/machine-learning/ml-problem-framing
Last updated: 2026-11-28

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](https://www.internhack.in/roadmaps/tracks/machine-learning/splits-and-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](https://scikit-learn.org/stable/getting_started.html) (scikit-learn)
- [Google ML Crash Course](https://developers.google.com/machine-learning/crash-course) (Google)
- [Kaggle Learn: Intro to Machine Learning](https://www.kaggle.com/learn/intro-to-machine-learning) (Kaggle)

Previous: [Train/Validation/Test Splits and Data Leakage](https://www.internhack.in/roadmaps/tracks/machine-learning/splits-and-leakage) · Next: [Linear Regression and Regularization](https://www.internhack.in/roadmaps/tracks/machine-learning/linear-regression)

## More in Classical Supervised Learning

- [Framing ML Problems and the scikit-learn API](https://www.internhack.in/roadmaps/tracks/machine-learning/ml-problem-framing)
- [Linear Regression and Regularization](https://www.internhack.in/roadmaps/tracks/machine-learning/linear-regression)
- [Logistic Regression and Linear Classifiers](https://www.internhack.in/roadmaps/tracks/machine-learning/logistic-regression)
- [k-Nearest Neighbours and Naive Bayes](https://www.internhack.in/roadmaps/tracks/machine-learning/knn-and-naive-bayes)
- [Decision Trees](https://www.internhack.in/roadmaps/tracks/machine-learning/decision-trees)
- [Bagging and Random Forests](https://www.internhack.in/roadmaps/tracks/machine-learning/random-forests)
- [Gradient Boosting with XGBoost and LightGBM](https://www.internhack.in/roadmaps/tracks/machine-learning/gradient-boosting)
- [Support Vector Machines and Kernels](https://www.internhack.in/roadmaps/tracks/machine-learning/support-vector-machines)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Machine Learning Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/machine-learning)
