Upload config1/training_marbles.py with huggingface_hub
Browse files- config1/training_marbles.py +61 -0
config1/training_marbles.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import datasets
|
| 4 |
+
|
| 5 |
+
class TrainingMarblesConfig1(datasets.GeneratorBasedBuilder):
|
| 6 |
+
VERSION = datasets.Version("1.0.0")
|
| 7 |
+
|
| 8 |
+
def _info(self):
|
| 9 |
+
return datasets.DatasetInfo(
|
| 10 |
+
features=datasets.Features(
|
| 11 |
+
{
|
| 12 |
+
'timestamp': datasets.Value('string'),
|
| 13 |
+
'marble_x': datasets.Value('float'),
|
| 14 |
+
'marble_y': datasets.Value('float'),
|
| 15 |
+
'boss_x': datasets.Value('float'),
|
| 16 |
+
'boss_y': datasets.Value('float'),
|
| 17 |
+
'triangle1_x': datasets.Value('float'),
|
| 18 |
+
'triangle1_y': datasets.Value('float'),
|
| 19 |
+
'triangle2_x': datasets.Value('float'),
|
| 20 |
+
'triangle2_y': datasets.Value('float'),
|
| 21 |
+
'triangle3_x': datasets.Value('float'),
|
| 22 |
+
'triangle3_y': datasets.Value('float'),
|
| 23 |
+
'marble_health': datasets.Value('float'),
|
| 24 |
+
'boss_health': datasets.Value('float'),
|
| 25 |
+
'command': datasets.Value('int32'),
|
| 26 |
+
}
|
| 27 |
+
)
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
def _split_generators(self, dl_manager):
|
| 31 |
+
data_dir = dl_manager.download_and_extract("path_to_config1_dataset_files")
|
| 32 |
+
return [
|
| 33 |
+
datasets.SplitGenerator(
|
| 34 |
+
name=datasets.Split.TRAIN,
|
| 35 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "X_train.csv")},
|
| 36 |
+
),
|
| 37 |
+
datasets.SplitGenerator(
|
| 38 |
+
name=datasets.Split.TEST,
|
| 39 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "X_test.csv")},
|
| 40 |
+
),
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
def _generate_examples(self, filepath):
|
| 44 |
+
df = pd.read_csv(filepath)
|
| 45 |
+
for id_, row in df.iterrows():
|
| 46 |
+
yield id_, {
|
| 47 |
+
'timestamp': row['timestamp'],
|
| 48 |
+
'marble_x': row['marble_x'],
|
| 49 |
+
'marble_y': row['marble_y'],
|
| 50 |
+
'boss_x': row['boss_x'],
|
| 51 |
+
'boss_y': row['boss_y'],
|
| 52 |
+
'triangle1_x': row['triangle1_x'],
|
| 53 |
+
'triangle1_y': row['triangle1_y'],
|
| 54 |
+
'triangle2_x': row['triangle2_x'],
|
| 55 |
+
'triangle2_y': row['triangle2_y'],
|
| 56 |
+
'triangle3_x': row['triangle3_x'],
|
| 57 |
+
'triangle3_y': row['triangle3_y'],
|
| 58 |
+
'marble_health': row['marble_health'],
|
| 59 |
+
'boss_health': row['boss_health'],
|
| 60 |
+
'command': row['command'],
|
| 61 |
+
}
|