mstz commited on
Commit
f0bd73f
1 Parent(s): 537e036

Upload arhythmia.py

Browse files
Files changed (1) hide show
  1. arhythmia.py +18 -1
arhythmia.py CHANGED
@@ -305,7 +305,7 @@ features_types_per_config = {
305
  "amplitude_of_t_wave_on_V6": datasets.Value("float64"),
306
  "qrsa_on_V6": datasets.Value("float64"),
307
  "qrsta_on_V6": datasets.Value("float64"),
308
- "type_of_arhythmia": datasets.ClassLabel(num_classes=17, names=["no_arhythmia"] + [f"arhythmia_of_type_{f}" for f in range(2, 16)] + ["unknown_arhythmia"])
309
  }
310
  }
311
  features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
@@ -354,5 +354,22 @@ class Arrhythmia(datasets.GeneratorBasedBuilder):
354
  "is_female": bool})
355
  if "type_of_arrhythmia" in data.columns:
356
  data = data.rename(columns={"type_of_arrhythmia": "type_of_arhythmia"})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
 
358
  return data[list(features_types_per_config[config].keys())]
 
305
  "amplitude_of_t_wave_on_V6": datasets.Value("float64"),
306
  "qrsa_on_V6": datasets.Value("float64"),
307
  "qrsta_on_V6": datasets.Value("float64"),
308
+ "type_of_arhythmia": datasets.ClassLabel(num_classes=13, names=["no_arhythmia"] + [f"arhythmia_of_type_{f}" for f in range(11)] + ["unknown_arhythmia"])
309
  }
310
  }
311
  features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
 
354
  "is_female": bool})
355
  if "type_of_arrhythmia" in data.columns:
356
  data = data.rename(columns={"type_of_arrhythmia": "type_of_arhythmia"})
357
+
358
+ label_encoding = {
359
+ 1: 0,
360
+ 2: 1,
361
+ 3: 2,
362
+ 4: 3,
363
+ 5: 4,
364
+ 6: 5,
365
+ 7: 6,
366
+ 8: 7,
367
+ 9: 8,
368
+ 10: 9,
369
+ 14: 10,
370
+ 15: 11,
371
+ 16: 12,
372
+ }
373
+ data.loc[:, "type_of_arhythmia"] = data["type_of_arhythmia"].apply(lambda x: label_encoding[x])
374
 
375
  return data[list(features_types_per_config[config].keys())]