Kiks & Learn
Start learning ↗
Machine Learning / Intermediate

Machine learning: build your first mental model

Build a beginner’s mental model of machine learning: define features and labels, make a baseline, evaluate carefully, and avoid data leakage.

YOUR FREE LEARNING PATH

Learn it here, one small step at a time.

4 guided lessons · About 2h 30m including practice · No subscription

  • Describe features, labels, and a baseline
  • Choose a split and metric that fit the task
  • Spot overfitting and data leakage

Recommended first: Python: your first practical programs, Pandas: explore real-world data. These foundations are suggestions, not a requirement to begin.

EXAMPLESknown examplesTRAINlearn patternTESTnew examples
Examples split into model training and evaluation
4 lessons · FreeOptional official free reference ↗
LESSON 01 / 30 MINUTES

Choose a prediction and define its inputs

Machine learning finds patterns in examples. The label is what you want to predict; features are the information available to make that prediction. For example, a model might use a home’s size and age to estimate its sale price. Be precise about when each feature is available.

Begin with a baseline: a simple rule you can beat, such as predicting the training-set average price. A complicated model is not useful unless it improves a meaningful measure on data it did not learn from.

A prediction setup
QuestionExample
LabelSale price
FeaturesSize and age at the time of listing
Prediction timeBefore the sale
BaselinePredict the average training price
TRY IT YOURSELF

Write a prediction question for a made-up dataset. Label the outcome, list two features, and note when each feature becomes available.

Reveal a suggested answer

Otherwise the model uses information it would not have when making a real prediction, creating an unrealistic score.

Optional further reading

Core lesson and practice are on this page. For more detail, visit the official free reference ↗.

LESSON 02 / 30 MINUTES

Separate data and choose a useful metric

A training set teaches the model. A held-out test set helps estimate how it performs on examples it has not seen. Do not repeatedly tune choices using the test set; that turns it into part of the training process. Keep related records together when splitting if they belong to the same person or event.

Choose a metric based on the cost of mistakes. Accuracy can look high when one class is much more common than another. For regression, compare prediction errors in units people understand.

Task and metric
TaskPossible metricWhat it measures
Predict a numeric amountMean absolute errorAverage size of the error
Flag a rare eventPrecision and recallCorrect alerts and missed events
Balanced class predictionAccuracy plus class detailsFraction classified correctly
TRY IT YOURSELF

A dataset has 95 normal cases and 5 rare cases. Explain why a model that always predicts “normal” has misleading 95% accuracy.

Reveal a suggested answer

How costly different kinds of mistakes are for the people using the prediction.

Optional further reading

Core lesson and practice are on this page. For more detail, visit the official free reference ↗.

LESSON 03 / 30 MINUTES

Train a model and compare it with a baseline

Training adjusts a model to fit examples. Make one change at a time, train using only the training set, and compare the result with your baseline on held-out data. Keep a record of the data split, features, model choice, and metric so the experiment can be repeated.

A model score is not the whole story. Check errors for different groups or ranges, inspect examples it gets wrong, and ask whether the input data represents the situation where the model will be used.

A small experiment log
RunChangeHeld-out result
BaselinePredict averageRecord score and units
Model AUse size featureCompare with baseline
Model BAdd age featureCheck improvement and errors
TRY IT YOURSELF

Write down the baseline first. Then add one feature and predict what should improve. Compare both results on exactly the same held-out examples.

Reveal a suggested answer

It shows whether the model adds value beyond a simple rule and gives you a fair point of comparison.

Optional further reading

Core lesson and practice are on this page. For more detail, visit the official free reference ↗.

LESSON 04 / 30 MINUTES

Recognize overfitting and leakage

Overfitting happens when a model learns details that work on its training examples but do not generalize. A much better training score than validation score is a warning. Data leakage occurs when training uses information unavailable at prediction time, including labels or future facts disguised as features.

Fit preprocessing steps only on the training data, then apply the fitted steps to validation and test data. After deployment, monitor whether the inputs and error patterns change; past performance is not a guarantee about the future.

Warning signs
SignalPossible problemNext check
Training score far betterOverfittingCompare against validation data
Future value in a featureLeakageCheck when the value exists
New population performs worseData shiftReview recent input and outcome patterns
TRY IT YOURSELF

Imagine predicting whether a customer will renew next month. Would “renewal date” be a safe input today? Explain your answer.

Reveal a suggested answer

The information is not available at prediction time, so the model would be tested with knowledge it cannot have in real use.

Optional further reading

Core lesson and practice are on this page. For more detail, visit the official free reference ↗.

CHECK YOUR UNDERSTANDING

Your final knowledge check.

Score 80% or more to pass. Sign in to save your best result.

1. Which dataset measures generalization?
2. How should you finish this learning path?

Sign in and start tracking this course to submit and save your score. Use each lesson’s self-check to practice without an account.

Learn together

Sign in to leave a comment →