Diabetes dataset.
| 10 | |
| 11 | |
| 12 | class NameDataset(Dataset): |
| 13 | """ Diabetes dataset.""" |
| 14 | |
| 15 | # Initialize your data, download, etc. |
| 16 | def __init__(self, is_train_set=False): |
| 17 | filename = './data/names_train.csv.gz' if is_train_set else './data/names_test.csv.gz' |
| 18 | with gzip.open(filename, "rt") as f: |
| 19 | reader = csv.reader(f) |
| 20 | rows = list(reader) |
| 21 | |
| 22 | self.names = [row[0] for row in rows] |
| 23 | self.countries = [row[1] for row in rows] |
| 24 | self.len = len(self.countries) |
| 25 | |
| 26 | self.country_list = list(sorted(set(self.countries))) |
| 27 | |
| 28 | def __getitem__(self, index): |
| 29 | return self.names[index], self.countries[index] |
| 30 | |
| 31 | def __len__(self): |
| 32 | return self.len |
| 33 | |
| 34 | def get_countries(self): |
| 35 | return self.country_list |
| 36 | |
| 37 | def get_country(self, id): |
| 38 | return self.country_list[id] |
| 39 | |
| 40 | def get_country_id(self, country): |
| 41 | return self.country_list.index(country) |
| 42 | |
| 43 | # Test the loader |
| 44 | if __name__ == "__main__": |
no outgoing calls
no test coverage detected