Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

Machine learning is a way for computers to find patterns in data and use those patterns to make predictions. Two of the most common prediction tasks are classification and regression. Classification sorts an input into a category, such as spam or not spam.

Regression predicts a number, such as a temperature, price, or test score.

Key Facts

  • Classification predicts a class label, such as cat, dog, pass, or fail.
  • Regression predicts a numerical value, such as y = 2x + 5.
  • A model is trained by comparing predictions to known answers in a training data set.
  • Classification accuracy = number of correct predictions / total number of predictions.
  • Regression error can be measured with mean absolute error: MAE = sum of |actual - predicted| / n.
  • The input features are the measurable clues the model uses, such as age, height, pixels, or study time.

Vocabulary

Classification
Classification is a machine learning task that predicts which category or group an input belongs to.
Regression
Regression is a machine learning task that predicts a continuous numerical value.
Feature
A feature is an input measurement or property that a model uses to make a prediction.
Training Data
Training data is a collection of examples with known answers used to teach a machine learning model.
Model
A model is the learned rule or pattern that connects input features to predicted outputs.

Common Mistakes to Avoid

  • Calling every prediction classification is wrong because some predictions are numbers, not categories. If the answer can vary along a number line, it is usually regression.
  • Treating labels like red, blue, and green as numbers is wrong when the numbers do not have real size or order. Category names should be handled as classes, not measurements.
  • Judging a regression model only by whether it is exactly correct is wrong because numerical predictions are often close but not perfect. Use error measures like MAE to measure how far off the predictions are.
  • Training and testing on the exact same examples is wrong because it can make the model look better than it really is. A separate test set checks whether the model works on new data.

Practice Questions

  1. 1 A classifier labels 50 emails as spam or not spam. It gets 42 correct. What is its accuracy as a fraction and as a percent?
  2. 2 A regression model predicts house prices of 210,000 dollars, 260,000 dollars, and 300,000 dollars. The actual prices are 200,000 dollars, 250,000 dollars, and 330,000 dollars. What is the mean absolute error?
  3. 3 Decide whether each task is classification or regression and explain why: predicting whether a plant is healthy or unhealthy, predicting tomorrow's high temperature, and predicting the type of animal in a photo.