Get startedGet started for free

Set parameters and fit a model

Predictive tasks fall into one of two categories: regression or classification. In the candy dataset, the outcome is a continuous variable describing how often the candy was chosen over another candy in a series of 1-on-1 match-ups. To predict this value (the win-percentage), you will use a regression model.

In this exercise, you will specify a few parameters using a random forest regression model rfr.

This exercise is part of the course

Model Validation in Python

View Course

Exercise instructions

  • Add a parameter to rfr so that the number of trees built is 100 and the maximum depth of these trees is 6.
  • Make sure the model is reproducible by adding a random state of 1111.
  • Use the .fit() method to train the random forest regression model with X_train as the input data and y_train as the response.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Set the number of trees
rfr.____ = ____

# Add a maximum depth
rfr.____ = ____

# Set the random state
rfr.____ = ____

# Fit the model
rfr.____(____, ____)
Edit and Run Code