ComeçarComece de graça

Preparing for RandomizedSearch

Last semester your professor challenged your class to build a predictive model to predict final exam test scores. You tried running a few different models by randomly selecting hyperparameters. However, running each model required you to code it individually.

After learning about RandomizedSearchCV(), you're revisiting your professors challenge to build the best model. In this exercise, you will prepare the three necessary inputs for completing a random search.

Este exercício faz parte do curso

Model Validation in Python

Ver curso

Instruções do exercício

  • Finalize the parameter dictionary by adding a list for the max_depth parameter with options 2, 4, 6, and 8.
  • Create a random forest regression model with ten trees and a random_state of 1111.
  • Create a mean squared error scorer to use.

Exercício interativo prático

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

from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import make_scorer, mean_squared_error

# Finish the dictionary by adding the max_depth parameter
param_dist = {"____": [____],
              "max_features": [2, 4, 6, 8, 10],
              "min_samples_split": [2, 4, 8, 16]}

# Create a random forest regression model
rfr = ____(____=10, ____=1111)

# Create a scorer to use (use the mean squared error)
scorer = ____(____)
Editar e executar o código