mstz commited on
Commit
a8c961c
·
1 Parent(s): fe18bda

Update acute_inflammation.py

Browse files
Files changed (1) hide show
  1. acute_inflammation.py +39 -7
acute_inflammation.py CHANGED
@@ -47,6 +47,28 @@ features_types_per_config = {
47
  "has_inflammed_bladder": datasets.Value("bool"),
48
  "has_nephritis_of_renal_pelvis": datasets.Value("bool"),
49
  "has_acute_inflammation": datasets.ClassLabel(num_classes=2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
  }
52
  features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
@@ -63,7 +85,11 @@ class Acute_Inflammation(datasets.GeneratorBasedBuilder):
63
  DEFAULT_CONFIG = "inflammation"
64
  BUILDER_CONFIGS = [
65
  Acute_InflammationConfig(name="inflammation",
66
- description="Binary classification of inflammation.")
 
 
 
 
67
  ]
68
 
69
 
@@ -77,7 +103,7 @@ class Acute_Inflammation(datasets.GeneratorBasedBuilder):
77
  downloads = dl_manager.download_and_extract(urls_per_split)
78
 
79
  return [
80
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]})
81
  ]
82
 
83
  def _generate_examples(self, filepath: str):
@@ -92,12 +118,18 @@ class Acute_Inflammation(datasets.GeneratorBasedBuilder):
92
  def preprocess(self, data: pandas.DataFrame, config: str = DEFAULT_CONFIG) -> pandas.DataFrame:
93
  data.columns = _BASE_FEATURE_NAMES
94
  boolean_features = ["has_nausea", "has_lumbar_pain", "has_urine_pushing",
95
- "has_micturition_pains", "has_burnt_urethra", "has_inflammed_bladder",
96
- "has_nephritis_of_renal_pelvis", "has_acute_inflammation"]
97
  for f in boolean_features:
98
  data.loc[:, f] = data[f].apply(lambda x: True if x == "yes" else False)
99
-
100
- data = data.astype({f: "bool" for f in boolean_features})
101
- data = data.astype({"has_acute_inflammation": int})
 
 
 
 
 
 
102
 
103
  return data
 
47
  "has_inflammed_bladder": datasets.Value("bool"),
48
  "has_nephritis_of_renal_pelvis": datasets.Value("bool"),
49
  "has_acute_inflammation": datasets.ClassLabel(num_classes=2)
50
+ },
51
+ "nephritis": {
52
+ "temperature": datasets.Value("float64"),
53
+ "has_nausea": datasets.Value("bool"),
54
+ "has_lumbar_pain": datasets.Value("bool"),
55
+ "has_urine_pushing": datasets.Value("bool"),
56
+ "has_micturition_pains": datasets.Value("bool"),
57
+ "has_burnt_urethra": datasets.Value("bool"),
58
+ "has_inflammed_bladder": datasets.Value("bool"),
59
+ "has_acute_inflammation": datasets.Value("bool"),
60
+ "has_nephritis_of_renal_pelvis": datasets.ClassLabel(num_classes=2)
61
+ },
62
+ "bladder": {
63
+ "temperature": datasets.Value("float64"),
64
+ "has_nausea": datasets.Value("bool"),
65
+ "has_lumbar_pain": datasets.Value("bool"),
66
+ "has_urine_pushing": datasets.Value("bool"),
67
+ "has_micturition_pains": datasets.Value("bool"),
68
+ "has_burnt_urethra": datasets.Value("bool"),
69
+ "has_acute_inflammation": datasets.Value("bool"),
70
+ "has_nephritis_of_renal_pelvis": datasets.Value("bool"),
71
+ "has_inflammed_bladder": datasets.ClassLabel(num_classes=2),
72
  }
73
  }
74
  features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
 
85
  DEFAULT_CONFIG = "inflammation"
86
  BUILDER_CONFIGS = [
87
  Acute_InflammationConfig(name="inflammation",
88
+ description="Binary classification of inflammation."),
89
+ Acute_InflammationConfig(name="nephritis",
90
+ description="Binary classification of nephritis."),
91
+ Acute_InflammationConfig(name="bladder",
92
+ description="Binary classification of bladder inflammation."),
93
  ]
94
 
95
 
 
103
  downloads = dl_manager.download_and_extract(urls_per_split)
104
 
105
  return [
106
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads[self.config.name]["train"]})
107
  ]
108
 
109
  def _generate_examples(self, filepath: str):
 
118
  def preprocess(self, data: pandas.DataFrame, config: str = DEFAULT_CONFIG) -> pandas.DataFrame:
119
  data.columns = _BASE_FEATURE_NAMES
120
  boolean_features = ["has_nausea", "has_lumbar_pain", "has_urine_pushing",
121
+ "has_micturition_pains", "has_burnt_urethra", "has_inflammed_bladder",
122
+ "has_nephritis_of_renal_pelvis", "has_acute_inflammation"]
123
  for f in boolean_features:
124
  data.loc[:, f] = data[f].apply(lambda x: True if x == "yes" else False)
125
+
126
+ if config == "inflammation":
127
+ data = data.astype({"has_acute_inflammation": int})
128
+ elif config == "nephritis"
129
+ data = data.astype({"has_nephritis_of_renal_pelvis": int})
130
+ elif config == "bladder":
131
+ data = data.astype({"has_inflammed_bladder": int})
132
+
133
+ data = data[list(features_types_per_config[config].keys())]
134
 
135
  return data