Learning from examples / 2 of 7

Regression and classification

8 minOpening your notebook…

What you’ll learn

  • Explain the main idea of “Regression and classification” in your own words.
  • Trace a concrete example and identify the assumptions behind it.
  • Apply the principle in a practice problem and recognize a common failure.

The idea, intuitively

Regression predicts a numeric quantity; classification predicts a category or category probabilities. Choose the target based on the decision rather than forcing every task into one model family.

Think of the dataset as a sample from a larger environment. A useful model must transfer beyond that sample. Keep training choices separate from final evaluation, and compare against a simple baseline. Before selecting an algorithm, inspect what the labels mean and which errors matter to the user.

Under the hood

Linear regression minimizes a numeric error such as mean squared error. Logistic regression transforms a linear score through a sigmoid for binary classification. A decision threshold converts probability into a label.

MSE=1n∑i(yi−y^i)2MSE=\frac{1}{n}\sum_i(y_i-\hat y_i)^2
For each of the n examples, subtract its prediction ŷᵢ from the observed target yᵢ, square that difference, and average the squares.
A useful caution

The name logistic regression can be misleading: it is commonly used for classification.

A worked example

Predicting tomorrow’s sales is regression. Predicting whether sales will exceed a threshold is classification, even though both use sales data.

How to use this way of thinking

Define the target, split the data, fit preprocessing only on training examples, and evaluate a baseline. Inspect individual failures alongside aggregate metrics. Change one major choice at a time and use validation evidence to decide whether the additional complexity earns its place.

Try it yourself

Calculate MSE for targets [2,4] and predictions [1,6].

Key takeaways

  • Estimated delivery time in minutes
  • The name logistic regression can be misleading: it is commonly used for classification.
  • Check the assumptions with a small example before applying this idea to a larger system.

Check your understanding

0/2 checked

Use feedback to learn. Quiz scores and lesson completion are tracked separately.

1Which target is a regression problem?
2True or false: Logistic regression is commonly used for classification.
Go to lesson completion

Further reading

Original papers and reference material for this school. External resources may be in English and require internet access.

Google Machine Learning Crash Course (opens a new tab)scikit-learn user guide (opens a new tab)

Finish this lesson

Mark this lesson complete when you’re ready to continue.

Start with a question

Introduction to AIAI FoundationsA brief history of AIAI FoundationsTypes of AIAI FoundationsAI, ML, and deep learningAI FoundationsUnderstanding generative AIAI FoundationsEthics, limitations, and responsibilityAI FoundationsLinear algebra for learning systemsMathematics for AIVectors, matrices, and similarityMathematics for AICalculus: measuring changeMathematics for AIDerivatives and gradientsMathematics for AIProbability and statisticsMathematics for AIOptimization and objectivesMathematics for AI
K to open · Escape to close