CommencerCommencer gratuitement

Train a simple model

As you determined, you are dealing with a regression problem. So, now you're ready to build a model for a subsequent submission. But now, instead of building the simplest Linear Regression model as in the slides, let's build an out-of-box Random Forest model.

You will use the RandomForestRegressor class from the scikit-learn library.

Your objective is to train a Random Forest model with default parameters on the "store" and "item" features.

Cet exercice fait partie du cours

Winning a Kaggle Competition in Python

Afficher le cours

Instructions

  • Read the train data using pandas.
  • Create a Random Forest object.
  • Train the Random Forest model on the "store" and "item" features with "sales" as a target.

Exercice interactif pratique

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

import pandas as pd
from sklearn.ensemble import RandomForestRegressor

# Read the train data
train = ____.____('train.csv')

# Create a Random Forest object
rf = ____()

# Train a model
rf.fit(X=train[['store', ____]], y=train['____'])
Modifier et exécuter le code