ComeçarComece de graça

Separate features and target variable

Now that you have split the data intro training and testing, it's time to perform he final step before fitting the model which is to separate the features and target variables into different datasets. You will use the list of columns names that have been loaded for you.

The main dataset is loaded as telcom, and split into training and testing datasets which are loaded as pandas DataFrames into train and test respectively. The target and custid lists contain the names of the target variable and the customer ID respectively. You will have to create the cols list with the names of the remaining columns. Feel free to explore the datasets in the console.

Este exercício faz parte do curso

Machine Learning for Marketing in Python

Ver curso

Instruções do exercício

  • Store the column names of telcom in a list excluding the target variable and customer ID names.
  • Extract the training features and target.
  • Extract the testing features and target.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Store column names from `telcom` excluding target variable and customer ID
cols = [col for col in ___.columns if col not in ___ + target]

# Extract training features
train_X = train[___]

# Extract training target
train_Y = train[___]

# Extract testing features
test_X = test[___]

# Extract testing target
test_Y = test[___]
Editar e executar o código