Regression
In this example, regression is the approach used to predict house prices.
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.
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.
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.
Tracing a House-Price Prediction
Show how a house-price example moves through the supervised-learning framework.
- 1Collect examples
Begin with examples in which housing inputs are accompanied by known house-price targets.
- 2Learn a mapping
Use the paired examples to discover a relationship between the housing inputs and the known targets.
- 3Present a new input
Provide housing inputs for a new example whose target is not yet being supplied to the model.
- 4Produce a prediction
Use the learned input-to-target relationship to predict the house price.
The task is supervised because the learning examples contain known targets, and it is regression because the stated goal is to predict house prices.
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 example | Role |
|---|---|
| Boston Housing Dataset | Provides the data |
| Regression | Provides the approach for predicting house prices |
| House price | The 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.
- 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
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.
| Part | Meaning |
|---|---|
| from | Begins an import from a specified location |
| keras.datasets | The location from which the dataset is imported |
| import | Requests the named item |
| boston_housing | The dataset name made available by the statement |
The import statement selects the Boston Housing Dataset from keras.datasets.
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 likeCalling boston_housing itself regression.Why it failsThe Boston Housing Dataset supplies the data, while regression is the approach used to predict house prices.
Do this insteadDescribe 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 likeReading the import statement as if it already learned a house-price mapping.
Why it failsThe source separates importing the dataset from performing regression with that dataset.
Do this insteadTreat 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 likeAssuming that every target must be a single class label.
Why it failsSupervised targets can also be house prices, sequences, syntax trees, bounding boxes, or pixel-level masks.
Do this insteadIdentify the task by examining the structure of its known target.
Common mistake Confusing object detection with image segmentation.
What it looks likeSaying that both tasks identify exactly the same target.
Why it failsObject detection identifies objects with bounding boxes, whereas image segmentation marks the pixels belonging to an object.
Do this insteadUse bounding boxes for the target description in detection and pixel-level masks for segmentation.
Check Your Understanding
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?
Reveal 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
- 1Supervised learning uses examples that pair inputs with known targets.
- 2The target's structure determines the task, including regression, classification, sequence generation, syntax-tree prediction, object detection, and image segmentation.
- 3The Boston Housing Dataset supplies data for the example, while regression is used to predict house prices.
- 4The statement from keras.datasets import
boston_housingmakes the dataset available under the nameboston_housing. - 5Importing 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_housingavailable; it does not complete the modeling task. - Different target structures lead to different supervised-learning tasks.