Upload 2 files
Browse files- README.md +24 -2
- heart_failure.py +10 -13
README.md
CHANGED
|
@@ -5,7 +5,7 @@ tags:
|
|
| 5 |
- heart failure
|
| 6 |
- tabular_classification
|
| 7 |
- binary_classification
|
| 8 |
-
pretty_name:
|
| 9 |
size_categories:
|
| 10 |
- 100<n<1K
|
| 11 |
task_categories: # Full list at https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts
|
|
@@ -14,4 +14,26 @@ configs:
|
|
| 14 |
- death
|
| 15 |
---
|
| 16 |
# Heart failure
|
| 17 |
-
The [Heart failure dataset](https://www.kaggle.com/datasets/andrewmvd/heart-failure-clinical-data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
- heart failure
|
| 6 |
- tabular_classification
|
| 7 |
- binary_classification
|
| 8 |
+
pretty_name: Heart failure
|
| 9 |
size_categories:
|
| 10 |
- 100<n<1K
|
| 11 |
task_categories: # Full list at https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts
|
|
|
|
| 14 |
- death
|
| 15 |
---
|
| 16 |
# Heart failure
|
| 17 |
+
The [Heart failure dataset](https://www.kaggle.com/datasets/andrewmvd/heart-failure-clinical-data) from Kaggle.
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# Configurations and tasks
|
| 21 |
+
The dataset has the following configurations:
|
| 22 |
+
- `death`, for binary classification of the patient death.
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# Features
|
| 26 |
+
|**Feature** |**Type** |
|
| 27 |
+
|---------------------------------------------------|-----------|
|
| 28 |
+
|`age` |`int8` |
|
| 29 |
+
|`has_anaemia` |`int8` |
|
| 30 |
+
|`creatinine_phosphokinase_concentration_in_blood` |`float64` |
|
| 31 |
+
|`has_diabetes` |`int8` |
|
| 32 |
+
|`heart_ejection_fraction` |`float64` |
|
| 33 |
+
|`has_high_blood_pressure` |`int8` |
|
| 34 |
+
|`platelets_concentration_in_blood` |`float64` |
|
| 35 |
+
|`serum_creatinine_concentration_in_blood` |`float64` |
|
| 36 |
+
|`serum_sodium_concentration_in_blood` |`float64` |
|
| 37 |
+
|`sex` |`int8` |
|
| 38 |
+
|`is_smoker` |`int8` |
|
| 39 |
+
|`days_in_study` |`int64` |
|
heart_failure.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
"""Heart Failure Dataset"""
|
| 2 |
|
| 3 |
from typing import List
|
| 4 |
-
from functools import partial
|
| 5 |
|
| 6 |
import datasets
|
| 7 |
|
|
@@ -79,27 +78,25 @@ class HeartFailure(datasets.GeneratorBasedBuilder):
|
|
| 79 |
return info
|
| 80 |
|
| 81 |
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
| 82 |
-
print("downloading...")
|
| 83 |
downloads = dl_manager.download_and_extract(urls_per_split)
|
| 84 |
-
print("downloaded!")
|
| 85 |
|
| 86 |
return [
|
| 87 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
|
| 88 |
]
|
| 89 |
|
| 90 |
def _generate_examples(self, filepath: str):
|
| 91 |
-
|
| 92 |
-
|
|
|
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
|
| 97 |
-
|
|
|
|
|
|
|
| 98 |
|
| 99 |
def preprocess(self, data: pandas.DataFrame, config: str = "death") -> pandas.DataFrame:
|
| 100 |
data.columns = _BASE_FEATURE_NAMES
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
return data
|
| 104 |
-
else:
|
| 105 |
-
raise ValueError(f"Unknown config: {config}")
|
|
|
|
| 1 |
"""Heart Failure Dataset"""
|
| 2 |
|
| 3 |
from typing import List
|
|
|
|
| 4 |
|
| 5 |
import datasets
|
| 6 |
|
|
|
|
| 78 |
return info
|
| 79 |
|
| 80 |
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
|
|
|
| 81 |
downloads = dl_manager.download_and_extract(urls_per_split)
|
|
|
|
| 82 |
|
| 83 |
return [
|
| 84 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
|
| 85 |
]
|
| 86 |
|
| 87 |
def _generate_examples(self, filepath: str):
|
| 88 |
+
if config == "death":
|
| 89 |
+
data = pandas.read_csv(filepath)
|
| 90 |
+
data = self.preprocess(data, config=self.config.name)
|
| 91 |
|
| 92 |
+
for row_id, row in data.iterrows():
|
| 93 |
+
data_row = dict(row)
|
| 94 |
|
| 95 |
+
yield row_id, data_row
|
| 96 |
+
else:
|
| 97 |
+
raise ValueError(f"Unknown config: {config}")
|
| 98 |
|
| 99 |
def preprocess(self, data: pandas.DataFrame, config: str = "death") -> pandas.DataFrame:
|
| 100 |
data.columns = _BASE_FEATURE_NAMES
|
| 101 |
+
|
| 102 |
+
return data
|
|
|
|
|
|
|
|
|