-
Jörg Martin authoredJörg Martin authored
california_housing.py 1.06 KiB
import torch
from EIVData.csv_dataset import CSVData
from torch.utils.data import random_split
def load_data(seed=0, splitting_part=0.8, normalize=True):
"""
Loads the california housing dataset
:param seed: Seed for splitting and shuffling the data.
Defaults to 0.
:param splitting_part: Which fraction of the data to use as training
data. Defaults to 0.8.
:normalize: Whether to normalize the data, defaults to True.
:returns: california_trainset, california_testset
"""
california_dataset = CSVData('~/SharedData/AI/datasets/california_housing/housing_reduced.csv',
class_name='median_house_value',
shuffle_seed=seed,
normalize=normalize)
dataset_len = len(california_dataset)
train_len = int(dataset_len*splitting_part)
test_len = dataset_len - train_len
california_trainset, california_testset = random_split(california_dataset,
lengths=[train_len, test_len],
generator=torch.Generator().manual_seed(seed))
return california_trainset, california_testset