Đại học Kinh tế Quốc dân – National Economics UniversityMICRO4ASIA
🏆 Arena
Sign inSign up
MICRO4ASIAThe six micro-credentials

Courses are delivered on the Limio learning platform. Limio

← Fundamental of Machine Learning

You are viewing a public preview

Sign in to save your progress, do assignments, join discussions and get feedback.

Sign in
Module 1: Data Preparation and Model Foundations

1.4 Regression, classification, clustering, association

Print / Save as PDF

1.4 Regression, classification, clustering, association

After this unit you will: be able to assign a problem to the correct type: regression, classification, clustering or association.

Key Points

GroupProblemExample on the slide
SupervisedRegression — the output is a continuous number“What will tomorrow's temperature be?” → 84°F
SupervisedClassification — the output is a label“Will tomorrow be hot or cold?” → HOT / COLD
UnsupervisedClustering — group points into clustersWhite dots → colored clusters
UnsupervisedAssociation — find rules that go togetherIf a customer buys item #1, recommend item #2

Study notes

By the end of this lesson you can:

  • Tell regression from classification by looking at the type of output.
  • Give real business examples of regression and classification problems.
  • Describe clustering and association as the two main unsupervised problems.
  • Assign a new problem to the right type: regression, classification, clustering or association.

Key idea: In supervised learning, regression predicts a continuous number and classification predicts a category from a fixed set. The type of the output, not the input, decides which one you have.

Supervised learning: regression and classification

The lecture uses one weather picture for both problems.

  • Regression: "What will the temperature be tomorrow?" The answer is a number on a scale, such as 84 degrees Fahrenheit. It could be any value, not just a few fixed options.
  • Classification: "Will it be hot or cold tomorrow?" The answer must be one of a fixed, limited set of classes: HOT or COLD. There is no value in between.

The lecturer calls this distinction probably the single most important concept in the whole course, because it decides which algorithms and which evaluation metrics you will use later.

RegressionClassification
OutputA continuous numberA category (class) from a fixed set
Weather exampleTomorrow's temperature: 84°FTomorrow: HOT or COLD
Other examplesHouse price, a person's salary, units sold next monthSpam or not spam, approve or reject a loan, cat or dog photo

A quick test: ask "Could the answer be 2.7 or 84.3?" If yes, it is regression. If the answer must be picked from a short list of names, it is classification. Note that the same inputs can serve both problems; only the question you ask about the output changes.

Unsupervised learning: clustering and association

Unsupervised learning has no labels, so it does not predict a known answer. The lecture shows two typical problems.

Clustering groups similar data points together without knowing in advance what the groups should be. On the slide, a cloud of white dots becomes three coloured groups (green, blue and red). The algorithm decided the groups; nobody told it. A retailer might analyse purchase histories and discover three natural customer segments, such as budget shoppers, premium shoppers and occasional buyers, without defining those segments beforehand.

Association discovers rules about items that go together: "if a customer buys item #1, recommend item #2". This is the logic behind "customers who bought this also bought..." recommendations on e-commerce websites.

GroupProblemOutputExample
SupervisedRegressionA numberTomorrow's temperature
SupervisedClassificationA labelHOT or COLD
UnsupervisedClusteringGroups of similar pointsCustomer segments
UnsupervisedAssociationIf-then rules between itemsBuy item #1, recommend item #2

This course focuses on supervised learning, so clustering and association appear only as context. You are likely to meet them later in your data science career.

Worked example

The same weather data can become a regression problem or a classification problem, depending on which target column you choose.

import pandas as pd

weather = pd.DataFrame({
    "day":    ["Mon", "Tue", "Wed", "Thu"],
    "temp_f": [84, 70, 91, 65],
})

# Regression target: the temperature itself (a continuous number)
y_regression = weather["temp_f"]

# Classification target: the same information turned into a label
weather["hot_or_cold"] = (weather["temp_f"] >= 80).map({True: "HOT", False: "COLD"})
y_classification = weather["hot_or_cold"]

print(weather)

Expected output:

   day  temp_f hot_or_cold
0  Mon      84         HOT
1  Tue      70        COLD
2  Wed      91         HOT
3  Thu      65        COLD

y_regression asks the model for a number such as 84. y_classification only asks for HOT or COLD. The threshold of 80°F is a business choice made for this example. Changing the question changed the problem type, so you would switch to a different family of algorithms and different metrics.

Common mistakes

  • Deciding the problem type from the inputs. Look at the output you want to predict, not at the input columns.
  • Calling a problem regression because the labels are stored as numbers. If 0 and 1 stand for "reject" and "approve", the problem is classification.
  • Expecting clustering to match labels you already have in mind. Clustering discovers its own groups; you interpret them afterwards.
  • Mixing up clustering and association. Clustering groups data points; association finds rules about which items occur together.

Summary

  • Regression predicts a continuous number, such as tomorrow's temperature of 84°F.
  • Classification predicts a class from a fixed set, such as HOT or COLD.
  • Regression versus classification is one of the most important distinctions in the course.
  • Clustering groups similar points without predefined groups; association finds rules like "buy item #1, recommend item #2".
  • Clustering and association belong to unsupervised learning, which this course covers only briefly.

Flashcards · 1.4 Regression, classification, clustering, association

8 words
WordMeaningExample
  • Regression

    A supervised problem where the model predicts a continuous numeric value.

    Predicting tomorrow's temperature: 84°F.

  • Classification

    A supervised problem where the model predicts one category from a fixed, limited set of classes.

    Will tomorrow be HOT or COLD?

  • Class

    One of the possible categories a classification model can output.

    "spam" and "not spam"

  • Continuous value

    A number that can take any value within a range, including decimals.

    A house price of 3.25 billion VND.

  • Clustering

    An unsupervised problem that groups similar data points without knowing the groups in advance.

    Discovering budget, premium and occasional shoppers.

  • Association

    An unsupervised problem that finds rules about items that tend to occur together.

    If a customer buys item #1, recommend item #2.

  • Customer segmentation

    Splitting customers into natural groups based on behaviour, a typical use of clustering.

    Grouping shoppers by purchase history.

  • Target type test

    Decide the problem type by asking whether the output is a number or a label.

    Salary: regression. Loan approved or not: classification.