tf.keras.datasets.california_housing.load_data
Stay organized with collections
Save and categorize content based on your preferences.
Loads the California Housing dataset.
tf.keras.datasets.california_housing.load_data(
version='large',
path='california_housing.npz',
test_split=0.2,
seed=113
)
This dataset was obtained from the StatLib repository.
It's a continuous regression dataset with 20,640 samples with
8 features each.
The target variable is a scalar: the median house value
for California districts, in dollars.
The 8 input features are the following:
- MedInc: median income in block group
- HouseAge: median house age in block group
- AveRooms: average number of rooms per household
- AveBedrms: average number of bedrooms per household
- Population: block group population
- AveOccup: average number of household members
- Latitude: block group latitude
- Longitude: block group longitude
This dataset was derived from the 1990 U.S. census, using one row
per census block group. A block group is the smallest geographical
unit for which the U.S. Census Bureau publishes sample data
(a block group typically has a population of 600 to 3,000 people).
A household is a group of people residing within a home.
Since the average number of rooms and bedrooms in this dataset are
provided per household, these columns may take surprisingly large
values for block groups with few households and many empty houses,
such as vacation resorts.
Args |
version
|
"small" or "large" . The small version
contains 600 samples, the large version contains
20,640 samples. The purpose of the small version is
to serve as an approximate replacement for the
deprecated boston_housing dataset.
|
path
|
path where to cache the dataset locally
(relative to ~/.keras/datasets ).
|
test_split
|
fraction of the data to reserve as test set.
|
seed
|
Random seed for shuffling the data
before computing the test split.
|
Returns |
Tuple of Numpy arrays: (x_train, y_train), (x_test, y_test) .
|
x_train
, x_test
: numpy arrays with shape (num_samples, 8)
containing either the training samples (for x_train
),
or test samples (for y_train
).
y_train
, y_test
: numpy arrays of shape (num_samples,)
containing the target scalars. The targets are float scalars
typically between 25,000 and 500,000 that represent
the home prices in dollars.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-06-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-07 UTC."],[],[],null,["# tf.keras.datasets.california_housing.load_data\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/datasets/california_housing.py#L9-L104) |\n\nLoads the California Housing dataset. \n\n tf.keras.datasets.california_housing.load_data(\n version='large',\n path='california_housing.npz',\n test_split=0.2,\n seed=113\n )\n\nThis dataset was obtained from the [StatLib repository](https://www.dcc.fc.up.pt/%7Eltorgo/Regression/cal_housing.html).\n\nIt's a continuous regression dataset with 20,640 samples with\n8 features each.\n\nThe target variable is a scalar: the median house value\nfor California districts, in dollars.\n\nThe 8 input features are the following:\n\n- MedInc: median income in block group\n- HouseAge: median house age in block group\n- AveRooms: average number of rooms per household\n- AveBedrms: average number of bedrooms per household\n- Population: block group population\n- AveOccup: average number of household members\n- Latitude: block group latitude\n- Longitude: block group longitude\n\nThis dataset was derived from the 1990 U.S. census, using one row\nper census block group. A block group is the smallest geographical\nunit for which the U.S. Census Bureau publishes sample data\n(a block group typically has a population of 600 to 3,000 people).\n\nA household is a group of people residing within a home.\nSince the average number of rooms and bedrooms in this dataset are\nprovided per household, these columns may take surprisingly large\nvalues for block groups with few households and many empty houses,\nsuch as vacation resorts.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `version` | `\"small\"` or `\"large\"`. The small version contains 600 samples, the large version contains 20,640 samples. The purpose of the small version is to serve as an approximate replacement for the deprecated `boston_housing` dataset. |\n| `path` | path where to cache the dataset locally (relative to `~/.keras/datasets`). |\n| `test_split` | fraction of the data to reserve as test set. |\n| `seed` | Random seed for shuffling the data before computing the test split. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Tuple of Numpy arrays: `(x_train, y_train), (x_test, y_test)`. ||\n\n\u003cbr /\u003e\n\n**`x_train`, `x_test`** : numpy arrays with shape `(num_samples, 8)`\ncontaining either the training samples (for `x_train`),\nor test samples (for `y_train`).\n\n**`y_train`, `y_test`** : numpy arrays of shape `(num_samples,)`\ncontaining the target scalars. The targets are float scalars\ntypically between 25,000 and 500,000 that represent\nthe home prices in dollars."]]