{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# \ud83d\udcc3 Solution for Exercise M6.01\n", "\n", "The aim of this notebook is to investigate if we can tune the hyperparameters\n", "of a bagging regressor and evaluate the gain obtained.\n", "\n", "We will load the California housing dataset and split it into a training and a\n", "testing set." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from sklearn.datasets import fetch_california_housing\n", "from sklearn.model_selection import train_test_split\n", "\n", "data, target = fetch_california_housing(as_frame=True, return_X_y=True)\n", "target *= 100 # rescale the target in k$\n", "data_train, data_test, target_train, target_test = train_test_split(\n", " data, target, random_state=0, test_size=0.5\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
Note
\n", "If you want a deeper overview regarding this dataset, you can refer to the\n", "Appendix - Datasets description section at the end of this MOOC.
\n", "Tip
\n", "You can list the bagging regressor's parameters using the get_params method.
\n", "