Menu

Separating Features and Target Variables

Separating Features and Target Variables

Before training the model, we must separate the target column from the feature columns.

Code

**X = house_price_df.drop(**

**"PRICE",**

**axis=1**

**)**

**y = house_price_df["PRICE"]**

Explanation

The variable X contains all input features.

The variable y contains the target variable that we want to predict.

After separation:

Variable

Content

X

Housing features

y

House prices

This structure is required by most machine learning libraries.