CommencerCommencer gratuitement

Predict next month transactions

You are finally in the stage of predicting next month's transaction with linear regression. Here you will use the input features you've previously built, train the model on them and the target variable, and predict the values on the unseen testing data. In the next exercise you will measure the model performance.

The LinearRegression function from sklearn library has been loaded for you. The training and testing features are loaded as train_X and test_X respectively, and the training and testing target variables are loaded as train_Y and test_Y.

Cet exercice fait partie du cours

Machine Learning for Marketing in Python

Afficher le cours

Instructions

  • Initialize a linear regression instance.
  • Fit the model to the training dataset.
  • Predict the target variable for the training data.
  • Predict the target variable for the testing data.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Initialize linear regression instance
linreg = ___()

# Fit the model to training dataset
linreg.___(___, ___)

# Predict the target variable for training data
train_pred_Y = linreg.___(___)

# Predict the target variable for testing data
test_pred_Y = linreg.___(___)
Modifier et exécuter le code