Custom Datasets
author: Juma Shafara date: "2024-09-04" title: Custom Datasets Practice keywords: [Training Two Parameter, Mini-Batch Gradient Decent, Training Two Parameter Mini-Batch Gradient Decent] description: In this lab, you will review how to make a prediction in several different ways by using PyTorch.

Custom Dataset Class
class BostonDataset(Dataset):
def __init__(self):
# define our dataset
self.data = boston_
self.x = torch.tensor(self.data.drop('MEDV', axis=1).values, dtype=torch.float32)
self.y = torch.tensor(self.data.MEDV.values, dtype=torch.float32)
self.samples = self.data.shape[0]
def __getitem__(self, index):
# access samples
return self.x[index], self.y[index]
def __len__(self):
# len(dataset)
return self.samples