QuestionQ93

VerifiedModel Development

A data scientist wants to tune a scikit-learn model’s hyperparameters efficiently. They choose to use the Hyperopt library’s fmin operation to support this process. Unfortunately, the final model is not very accurate. The data scientist suspects an issue with the objective_function passed to fmin.

They use the following code block to create the objective_function:

Question Image

Which change must the data scientist make to their objective_function to produce a more accurate model?

Explanation

Hyperopt fmin minimizes its objective value, while the mean cross-validation score for a regressor is R² by default, and higher R² is better. Returning -r2 converts the maximization of R² into a minimization objective, so hyperparameter search selects configurations with better predictive performance.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!