- Load the data from the California housing dataset once again. Observe how we create bins once more to stratify a continuous variable:
%matplotlib inlineimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom sklearn.datasets import fetch_california_housingcali_housing = fetch_california_housing()X = cali_housing.datay = cali_housing.targetbins = np.arange(6) from __future__ import divisionfrom sklearn.model_selection import train_test_splitbinned_y = np.digitize(y, bins)from sklearn.ensemble import RandomForestRegressor, AdaBoostRegressor, ExtraTreesRegressor, GradientBoostingRegressor from sklearn.model_selection import GridSearchCV
- Now split the pair, X and y, into three X and y pairs, input and output, ...