MACHINE LEARNING • LESSON 5

What Are Features?

Features are the pieces of information that a Machine Learning model uses as input to make a prediction or decision.

THE CORE IDEA

Features are the information we give to the model so it can learn useful patterns.

If we want a model to predict house prices, features might include house size, number of bedrooms, location, and age.

01

Start With a Real-World Problem

Imagine that we want to build a Machine Learning model that predicts the price of a house.

We have many historical house records and each record contains different pieces of information.

SIZE 1,800 sq ft
BEDROOMS 3
AGE 8 years
LOCATION City Center

These pieces of information can be used by the model to make a prediction.

02

These Inputs Are Features

In the example above, the house size, number of bedrooms, age, and location are all potential features.

FEATURE A piece of input information used by a Machine Learning model.

Features describe the example that the model is looking at.

03

Another Example: Spam Detection

Suppose we want to build a model that predicts whether an email is spam.

The model could use information such as:

FEATURE 01 Number of Links

How many links appear in the email?

FEATURE 02 Message Length

How long is the email?

FEATURE 03 Sender Information

Information about the sender.

FEATURE 04 Keyword Patterns

Certain words or patterns found in the message.

04

Features Are the Inputs

A useful way to remember the idea is:

INPUT Features

Information about the example.

MODEL Learns Patterns

Finds relationships in the data.

OUTPUT Prediction

The result produced by the model.

05

One Row Can Contain Many Features

Consider one house record:

SIZE 1800
BEDROOMS 3
AGE 8
LOCATION City

This single row represents one example, and each relevant input column can act as a feature.

06

Features Can Be Numbers

Many features are numerical.

HOUSE SIZE 1800

square feet

BEDROOMS 3

bedrooms

AGE 8

years

Numerical features are often directly represented as numbers, although preprocessing may still be needed depending on the model and problem.

07

Features Can Also Be Categories

Not every feature is naturally a number.

For example, a house location might be:

LOCATION City Center

Machine Learning algorithms usually require data in a numerical representation, so categorical information often needs to be encoded before it can be used by a model.

08

More Features Do Not Automatically Mean a Better Model

This is an important point.

You might think that adding every available column will automatically improve the model.

It won't.

Bad features can hurt a model.

Irrelevant, duplicated, noisy, or misleading information can make learning harder and can sometimes cause the model to perform worse.

Example 1

House price prediction may benefit from house size, but a random internal record ID probably provides no useful information about price.

Example 2

A spam classifier may benefit from message patterns, but an unrelated database identifier should not automatically be treated as a useful feature.

09

Features Should Be Available at Prediction Time

Another common mistake is using information that would not actually be available when the model makes its prediction.

Ask this question:

"Will this information actually exist at the time I need the prediction?"

Example 1

If you want to predict whether a customer will purchase tomorrow, using tomorrow's purchase information as a feature would be meaningless.

Example 2

If you want to predict whether a transaction is fraudulent before approving it, using information that only becomes available after the transaction is investigated would create leakage.

10

Features in a Dataset

Suppose our dataset looks like this:

Size Bedrooms Age Location Price
1800 3 8 City $320,000
2200 4 5 Suburb $410,000
1400 2 15 Town $240,000

In this example, the first four columns can be used as features for predicting the house price.

11

Features vs the Thing We Want to Predict

Notice that the table contains another important column: Price.

Price is not an input feature in this example. It is the value we want the model to predict.

INPUT Features

Size, bedrooms, age, location

TARGET Price

Value we want the model to predict

The target is commonly called the label in supervised Machine Learning.

12

The Simple Mental Model

FEATURES What we know

Information given to the model.

MODEL What it learns

Patterns and relationships.

LABEL / TARGET What we want

The value or category we want to predict.

KEY IDEA

Features Are the Model's Inputs

Features describe each example and provide the information from which a Machine Learning model can learn patterns. The value we want to predict is usually called the target or label.

QUICK CHECK

Which Ones Are Features?

You want to predict whether a customer will purchase a product.

Your dataset contains:

  • Customer age.
  • Number of previous purchases.
  • Product category.
  • Whether the customer purchased the product.
Answer

Customer age, previous purchases, and product category can be features.

Whether the customer purchased the product is the target or label we want to predict.

NEXT TOPIC

What Are Labels?

We now know what the model uses as input. Next, we'll look at the value the model is trying to predict and why it is called a label or target.