import os import pandas as pd import datasets class TrainingMarblesConfig2(datasets.GeneratorBasedBuilder): VERSION = datasets.Version("1.0.0") def _info(self): return datasets.DatasetInfo( features=datasets.Features( { 'timestamp': datasets.Value('string'), 'marble_x': datasets.Value('float'), 'marble_y': datasets.Value('float'), 'boss_x': datasets.Value('float'), 'boss_y': datasets.Value('float'), 'triangle1_x': datasets.Value('float'), 'triangle1_y': datasets.Value('float'), 'triangle2_x': datasets.Value('float'), 'triangle2_y': datasets.Value('float'), 'triangle3_x': datasets.Value('float'), 'triangle3_y': datasets.Value('float'), 'marble_health': datasets.Value('float'), 'boss_health': datasets.Value('float'), 'command': datasets.Value('int32'), } ) ) def _split_generators(self, dl_manager): data_dir = dl_manager.download_and_extract("path_to_config2_dataset_files") return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={"filepath": os.path.join(data_dir, "X_train.csv")}, ), datasets.SplitGenerator( name=datasets.Split.TEST, gen_kwargs={"filepath": os.path.join(data_dir, "X_test.csv")}, ), ] def _generate_examples(self, filepath): df = pd.read_csv(filepath) for id_, row in df.iterrows(): yield id_, { 'timestamp': row['timestamp'], 'marble_x': row['marble_x'], 'marble_y': row['marble_y'], 'boss_x': row['boss_x'], 'boss_y': row['boss_y'], 'triangle1_x': row['triangle1_x'], 'triangle1_y': row['triangle1_y'], 'triangle2_x': row['triangle2_x'], 'triangle2_y': row['triangle2_y'], 'triangle3_x': row['triangle3_x'], 'triangle3_y': row['triangle3_y'], 'marble_health': row['marble_health'], 'boss_health': row['boss_health'], 'command': row['command'], }