ComenzarEmpieza gratis

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 ejercicio forma parte del curso

Model Validation in Python

Ver curso

Instrucciones del ejercicio

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

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

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 y ejecutar código