ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Winning a Kaggle Competition in Python

Ver curso

Instrucciones del ejercicio

  • 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.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

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['____'])
Editar y ejecutar código