Concepts / Regression

Regression

In this example, regression is the approach used to predict house prices.

  • Programming

Why Known Answers Matter

Suppose a learning system receives information about a house and must predict its price. The system needs examples that connect housing inputs with known house-price targets. This pairing is the foundation of supervised learning and is what makes the house-price task a regression example.

Definition

Supervised learning connects inputs with known targets through a collection of examples. The target is the answer the system is expected to learn; targets are also called annotations.

Training examplesa collectionInputsinformation about anexampleKnown targetsexpected answerscontainscontainspaired with
What is contained in each supervised-learning example, and how are inputs connected to their known targets?

From Examples to a Prediction

Supervised learning can be understood as a change in the role of the data. At the beginning, the collection contains inputs together with their known targets. The learner uses those examples to discover a mapping from inputs to targets. After learning, the result is a model that represents this input-to-target relationship. When a new input is presented, the model uses that relationship to produce a prediction.

Worked example

Tracing a House-Price Prediction

Show how a house-price example moves through the supervised-learning framework.

  1. 1
    Collect examples

    Begin with examples in which housing inputs are accompanied by known house-price targets.

  2. 2
    Learn a mapping

    Use the paired examples to discover a relationship between the housing inputs and the known targets.

  3. 3
    Present a new input

    Provide housing inputs for a new example whose target is not yet being supplied to the model.

  4. 4
    Produce a prediction

    Use the learned input-to-target relationship to predict the house price.

Result

The task is supervised because the learning examples contain known targets, and it is regression because the stated goal is to predict house prices.

Housing inputsRegression modellearned input-to-targetmappingPredicted house priceprovided toproduces
How do housing features flow through a regression model to produce a predicted house price?
Key point

The essential supervised-learning relationship is not merely data going into a system. It is input data paired with the known target that the system is expected to learn.

House Prices as Regression

The Boston Housing Dataset supplies the data for the regression example. In this example, regression is the approach used to predict house prices. The dataset provides the exercise's data; regression describes the kind of prediction being made with that data.

Part of the exampleRole
Boston Housing DatasetProvides the data
RegressionProvides the approach for predicting house prices
House priceThe target being predicted

The dataset and the modeling task are related, but they are not the same thing.

Target Shapes Define Tasks

The structure of the target determines the supervised-learning task. A target may be a category, a house price, a complete sequence, a syntax tree, a set of bounding boxes, or a pixel-level mask. In every case, the framework remains the same: examples connect inputs with known targets, but the target's form changes what the model must predict.

ClassificationcategoryRegressionhouse priceSequence generationordered outputSyntax-treepredictionnested structureObject detectionobjects and boxesImage segmentationpixel masktarget formtarget formtarget formtarget formtarget formtarget form
How does the form of the target differ between regression, classification, sequence generation, syntax-tree prediction, object detection, and image segmentation?
  • Sequence generation predicts an ordered output such as a caption. It can be treated as repeated classification, with the system repeatedly choosing the next word or token.
  • Syntax-tree prediction uses a target that describes the nested structure of a sentence.
  • Object detection identifies objects with bounding boxes. It can involve classification of candidate boxes or a combination of classification and regression for predicting box coordinates.
  • Image segmentation identifies the pixels belonging to a specific object by producing a pixel-level mask.

Reading the Keras Import

python

Read the statement from left to right. It imports boston_housing from keras.datasets. After this statement, the boston_housing dataset is available under that name for the regression example.

PartMeaning
fromBegins an import from a specified location
keras.datasetsThe location from which the dataset is imported
importRequests the named item
boston_housingThe dataset name made available by the statement

The import statement selects the Boston Housing Dataset from keras.datasets.

Key point

This line makes the dataset available. It does not, by itself, perform regression or produce a house-price prediction.

Mistakes About the Example

  • Common mistake

    Treating the dataset name as the name of the prediction method.

    What it looks like
    Calling boston_housing itself regression.
    Why it fails

    The Boston Housing Dataset supplies the data, while regression is the approach used to predict house prices.

    Do this instead

    Describe the example as regression applied to data supplied by the Boston Housing Dataset.

  • Common mistake

    Assuming that importing the dataset completes the learning process.

    What it looks like

    Reading the import statement as if it already learned a house-price mapping.

    Why it fails

    The source separates importing the dataset from performing regression with that dataset.

    Do this instead

    Treat the import as the data-access step and regression as a separate part of the overall example.

  • Common mistake

    Defining supervised learning only as category prediction.

    What it looks like

    Assuming that every target must be a single class label.

    Why it fails

    Supervised targets can also be house prices, sequences, syntax trees, bounding boxes, or pixel-level masks.

    Do this instead

    Identify the task by examining the structure of its known target.

  • Common mistake

    Confusing object detection with image segmentation.

    What it looks like

    Saying that both tasks identify exactly the same target.

    Why it fails

    Object detection identifies objects with bounding boxes, whereas image segmentation marks the pixels belonging to an object.

    Do this instead

    Use bounding boxes for the target description in detection and pixel-level masks for segmentation.

Check Your Understanding

MEDIUM

A learner writes the Keras import statement for the Boston Housing Dataset and then says, “The program has now performed regression.” Is that conclusion correct? Explain the separate roles of the import and the regression example. Then classify each target form: a house price, a caption, a sentence's nested structure, an object's bounding box, and an object's pixel mask.

Hints
  • Ask whether the statement makes data available or applies a learned input-to-target mapping.
  • Identify the target structure before naming the task.
  • A caption is an ordered output, while a pixel mask identifies pixels belonging to an object.

What do you think happens?

What does this statement accomplish by itself: from keras.datasets import boston_housing?

  • It makes the dataset available under the name boston_housing.

  • It performs regression and predicts a house price.

  • It creates a pixel-level image mask.

Reveal answer
Answer:

It makes the dataset available under the name boston_housing.

The source distinguishes importing the dataset from performing regression with that dataset. The import is the data-selection step, not the complete prediction process.

Key Takeaways

  1. 1
    Supervised learning uses examples that pair inputs with known targets.
  2. 2
    The target's structure determines the task, including regression, classification, sequence generation, syntax-tree prediction, object detection, and image segmentation.
  3. 3
    The Boston Housing Dataset supplies data for the example, while regression is used to predict house prices.
  4. 4
    The statement from keras.datasets import boston_housing makes the dataset available under the name boston_housing.
  5. 5
    Importing a dataset and performing regression are separate parts of the overall example.

At a glance

  • Supervised learning connects inputs with known targets through examples.
  • Regression is the approach used in this example to predict house prices.
  • The Boston Housing Dataset provides the data but does not itself perform regression.
  • The Keras import statement makes boston_housing available; it does not complete the modeling task.
  • Different target structures lead to different supervised-learning tasks.

Related concepts

More concepts starting with R