Load the California housing dataset (regression).
Samples total | 20640 |
Dimensionality | 8 |
Features | real |
Target | real 0.15 - 5. |
Read more in the User Guide.
Specify another download and cache folder for the datasets. By default all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
If False, raise an OSError if the data is not locally available instead of trying to download the data from the source site.
If True, returns (data.data, data.target) instead of a Bunch object.
Added in version 0.20.
If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric, string or categorical). The target is a pandas DataFrame or Series depending on the number of target_columns.
Added in version 0.23.
Number of retries when HTTP errors are encountered.
Added in version 1.5.
Number of seconds between retries.
Added in version 1.5.
Bunch
Dictionary-like object, with the following attributes.
Each row corresponding to the 8 feature values in order. If as_frame is True, data is a pandas object.
Each value corresponds to the average house value in units of 100,000. If as_frame is True, target is a pandas object.
Array of ordered feature names used in the dataset.
Description of the California housing dataset.
Only present when as_frame=True. DataFrame with data and target.
Added in version 0.23.
return_X_y is True
A tuple of two ndarray. The first containing a 2D array of shape (n_samples, n_features) with each row representing one sample and each column representing the features. The second ndarray of shape (n_samples,) containing the target samples.
Added in version 0.20.
This dataset consists of 20,640 samples and 9 features.
>>> from sklearn.datasets import fetch_california_housing >>> housing = fetch_california_housing() >>> print(housing.data.shape, housing.target.shape) (20640, 8) (20640,) >>> print(housing.feature_names[0:6]) ['MedInc', 'HouseAge', 'AveRooms', 'AveBedrms', 'Population', 'AveOccup']
© 2007–2025 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/1.6/modules/generated/sklearn.datasets.fetch_california_housing.html