I want to create a custom dataset where I can read a CSV file and do the following lambda function. I have created a part of the class but I am getting an error for the map
and concatenate
function.
Errors:
AttributeError: 'ConcatDataset' object has no attribute 'map'
AttributeError: 'map' object has no attribute 'map'
This is my dataset class.
class MyDataset(Dataset):
def __init__(self, csv_path):
self.df = pd.read_csv(csv_path, index_col=False)
def __getitem__(self, index):
return self.df.iloc[index, :].to_dict()
def __len__(self):
return len(self.df)
def map(self, func):
return map(func, self)
def concatenate(self, dataset):
# cocatenate dataset
I want to do the following;
mydataset = MyDataset("train_data.csv")
datasets = []
for k in range(5):
datasets.append(mydataset.map(lambda x: some_function)
dataset = datasets[-1]
for d in datasets[:-1]:
dataset = dataset.concatenate(d)
Also,
# again do mapping
dataset = dataset.map(lambda x: x ** 2)
# and also some other functions like
dataset.repeat()
dataset.filter()
From what I understood the error is coming because the function is not returning the object of the same class.
Thanks in advance!