Datasets:
Upload 3 files
Browse files- README.md +24 -1
- post-operative.data +91 -0
- post_operative.py +114 -0
README.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
tags:
|
5 |
+
- post_operative
|
6 |
+
- tabular_classification
|
7 |
+
- binary_classification
|
8 |
+
- multiclass_classification
|
9 |
+
pretty_name: Page Blocks
|
10 |
+
size_categories:
|
11 |
+
- 1K<n<10K
|
12 |
+
task_categories: # Full list at https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts
|
13 |
+
- tabular-classification
|
14 |
+
configs:
|
15 |
+
- post_operative
|
16 |
+
- post_operative_binary
|
17 |
---
|
18 |
+
# Post Operative
|
19 |
+
The [PostOperative dataset](https://archive-beta.ics.uci.edu/dataset/82/post+operative+patient) from the [UCI repository](https://archive-beta.ics.uci.edu/).
|
20 |
+
Should the patient be discharged from the hospital?
|
21 |
+
|
22 |
+
# Configurations and tasks
|
23 |
+
| **Configuration** | **Task** |
|
24 |
+
|-------------------|---------------------------|
|
25 |
+
| post_operative | Multiclass classification |
|
26 |
+
| post_operative_binary| Binary classification |
|
post-operative.data
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
internal_temperature,surface_temperature,oxigen_saturation,blood_pressure,surface_temperature_stability,internal_temperature_stability,blood_pressure_stability,perceived_comfort,decision
|
2 |
+
mid,low,excellent,mid,stable,stable,stable,15,0
|
3 |
+
mid,high,excellent,high,stable,stable,stable,10,1
|
4 |
+
high,low,excellent,high,stable,stable,mod-stable,10,0
|
5 |
+
mid,low,good,high,stable,unstable,mod-stable,15,A
|
6 |
+
mid,mid,excellent,high,stable,stable,stable,10,0
|
7 |
+
high,low,good,mid,stable,stable,unstable,15,1
|
8 |
+
mid,low,excellent,high,stable,stable,mod-stable,05,1
|
9 |
+
high,mid,excellent,mid,unstable,unstable,stable,10,1
|
10 |
+
mid,high,good,mid,stable,stable,stable,10,1
|
11 |
+
mid,low,excellent,mid,unstable,stable,mod-stable,10,1
|
12 |
+
mid,mid,good,mid,stable,stable,stable,15,0
|
13 |
+
mid,low,good,high,stable,stable,mod-stable,10,0
|
14 |
+
high,high,excellent,high,unstable,stable,unstable,15,0
|
15 |
+
mid,high,good,mid,unstable,stable,mod-stable,10,0
|
16 |
+
mid,low,good,high,unstable,unstable,stable,15,1
|
17 |
+
high,high,excellent,high,unstable,stable,unstable,10,0
|
18 |
+
low,high,good,high,unstable,stable,mod-stable,15,0
|
19 |
+
mid,low,good,high,unstable,stable,stable,10,0
|
20 |
+
mid,high,good,mid,unstable,stable,unstable,15,0
|
21 |
+
mid,mid,good,mid,stable,stable,stable,10,0
|
22 |
+
low,high,good,mid,unstable,stable,stable,15,0
|
23 |
+
low,mid,excellent,high,unstable,stable,unstable,10,1
|
24 |
+
mid,mid,good,mid,unstable,stable,unstable,15,0
|
25 |
+
mid,mid,good,mid,unstable,stable,stable,10,0
|
26 |
+
high,high,good,mid,stable,stable,mod-stable,10,0
|
27 |
+
low,mid,good,mid,unstable,stable,stable,10,0
|
28 |
+
high,mid,good,low,stable,stable,mod-stable,10,0
|
29 |
+
low,mid,excellent,high,stable,stable,mod-stable,10,0
|
30 |
+
mid,mid,excellent,mid,stable,stable,unstable,15,0
|
31 |
+
mid,mid,good,mid,unstable,stable,unstable,10,1
|
32 |
+
mid,mid,good,high,unstable,stable,stable,10,0
|
33 |
+
low,low,good,mid,unstable,stable,unstable,10,0
|
34 |
+
mid,mid,excellent,high,unstable,stable,mod-stable,10,0
|
35 |
+
mid,low,good,mid,stable,stable,stable,10,0
|
36 |
+
low,mid,excellent,high,stable,stable,mod-stable,10,0
|
37 |
+
mid,mid,good,mid,stable,stable,stable,10,0
|
38 |
+
low,mid,excellent,mid,stable,stable,stable,10,1
|
39 |
+
low,low,good,mid,unstable,stable,unstable,10,1
|
40 |
+
low,low,good,mid,stable,stable,stable,07,1
|
41 |
+
mid,mid,good,high,unstable,stable,mod-stable,10,0
|
42 |
+
low,low,good,mid,unstable,stable,stable,10,0
|
43 |
+
low,mid,good,mid,stable,stable,stable,15,1
|
44 |
+
high,high,good,high,unstable,stable,stable,15,1
|
45 |
+
mid,mid,good,mid,stable,stable,stable,10,1
|
46 |
+
low,low,excellent,mid,stable,stable,stable,10,0
|
47 |
+
low,mid,good,mid,unstable,stable,stable,10,1
|
48 |
+
low,mid,good,high,unstable,stable,stable,?,2
|
49 |
+
mid,mid,excellent,mid,unstable,stable,stable,10,0
|
50 |
+
high,high,excellent,high,stable,stable,unstable,?,0
|
51 |
+
mid,high,good,low,unstable,stable,stable,10,0
|
52 |
+
mid,high,good,mid,unstable,mod-stable,mod-stable,10,0
|
53 |
+
low,high,excellent,mid,unstable,stable,stable,10,0
|
54 |
+
mid,low,excellent,high,unstable,stable,unstable,10,0
|
55 |
+
mid,mid,good,mid,unstable,stable,mod-stable,10,1
|
56 |
+
high,high,excellent,mid,unstable,stable,mod-stable,10,0
|
57 |
+
mid,mid,good,mid,unstable,stable,stable,15,0
|
58 |
+
high,mid,good,high,stable,stable,unstable,15,0
|
59 |
+
mid,low,good,high,unstable,stable,mod-stable,10,0
|
60 |
+
low,low,good,high,stable,stable,stable,10,0
|
61 |
+
mid,high,good,mid,stable,stable,mod-stable,10,0
|
62 |
+
mid,high,good,mid,unstable,stable,unstable,10,0
|
63 |
+
mid,low,excellent,high,stable,stable,stable,10,0
|
64 |
+
mid,mid,good,mid,stable,stable,unstable,10,0
|
65 |
+
mid,low,excellent,mid,stable,stable,unstable,10,1
|
66 |
+
high,mid,excellent,mid,unstable,unstable,unstable,10,0
|
67 |
+
mid,mid,good,high,stable,stable,stable,10,1
|
68 |
+
mid,low,excellent,mid,unstable,stable,stable,10,0
|
69 |
+
mid,mid,excellent,mid,unstable,stable,stable,10,0
|
70 |
+
mid,mid,excellent,high,stable,stable,stable,10,0
|
71 |
+
mid,mid,excellent,low,stable,stable,stable,10,0
|
72 |
+
mid,low,excellent,mid,unstable,unstable,unstable,?,0
|
73 |
+
low,low,excellent,mid,stable,stable,stable,10,0
|
74 |
+
mid,mid,excellent,mid,stable,stable,mod-stable,10,1
|
75 |
+
mid,mid,excellent,high,stable,stable,stable,10,0
|
76 |
+
mid,low,excellent,high,stable,stable,mod-stable,10,0
|
77 |
+
low,mid,good,mid,stable,stable,unstable,10,0
|
78 |
+
mid,mid,excellent,mid,stable,stable,mod-stable,10,0
|
79 |
+
mid,mid,excellent,mid,stable,stable,unstable,10,0
|
80 |
+
mid,mid,excellent,mid,unstable,unstable,stable,10,1
|
81 |
+
mid,mid,good,high,stable,stable,stable,10,0
|
82 |
+
mid,mid,excellent,mid,stable,stable,stable,15,0
|
83 |
+
mid,mid,excellent,mid,stable,stable,stable,10,1
|
84 |
+
mid,low,good,mid,stable,stable,unstable,10,2
|
85 |
+
high,mid,excellent,mid,unstable,stable,unstable,05,0
|
86 |
+
mid,mid,excellent,mid,stable,stable,unstable,10,0
|
87 |
+
mid,mid,excellent,mid,unstable,stable,stable,10,0
|
88 |
+
mid,mid,excellent,mid,unstable,stable,stable,15,1
|
89 |
+
mid,mid,good,mid,unstable,stable,stable,15,0
|
90 |
+
mid,mid,excellent,mid,unstable,stable,stable,10,0
|
91 |
+
mid,mid,good,mid,unstable,stable,stable,15,1
|
post_operative.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""PostOperative Dataset"""
|
2 |
+
|
3 |
+
from typing import List
|
4 |
+
from functools import partial
|
5 |
+
|
6 |
+
import datasets
|
7 |
+
|
8 |
+
import pandas
|
9 |
+
|
10 |
+
|
11 |
+
VERSION = datasets.Version("1.0.0")
|
12 |
+
|
13 |
+
_ENCODING_DICS = {
|
14 |
+
}
|
15 |
+
|
16 |
+
DESCRIPTION = "PostOperative dataset."
|
17 |
+
_HOMEPAGE = "https://archive-beta.ics.uci.edu/dataset/78/page+blocks+classification"
|
18 |
+
_URLS = ("https://archive-beta.ics.uci.edu/dataset/78/page+blocks+classification")
|
19 |
+
_CITATION = """
|
20 |
+
@misc{misc_post-operative_patient_82,
|
21 |
+
author = {Summers,Sharon & Woolery,Linda},
|
22 |
+
title = {{Post-Operative Patient}},
|
23 |
+
year = {1993},
|
24 |
+
howpublished = {UCI Machine Learning Repository},
|
25 |
+
note = {{DOI}: \\url{10.24432/C5DG6Q}}
|
26 |
+
}"""
|
27 |
+
|
28 |
+
# Dataset info
|
29 |
+
urls_per_split = {
|
30 |
+
"train": "https://huggingface.co/datasets/mstz/post_operative/raw/main/post_operative.data"
|
31 |
+
}
|
32 |
+
features_types_per_config = {
|
33 |
+
"post_operative": {
|
34 |
+
"internal_temperature": datasets.Value("int8"),
|
35 |
+
"surface_temperature": datasets.Value("int8"),
|
36 |
+
"oxigen_saturation": datasets.Value("int8"),
|
37 |
+
"blood_pressure": datasets.Value("int8"),
|
38 |
+
"surface_temperature_stability": datasets.Value("int8"),
|
39 |
+
"internal_temperature_stability": datasets.Value("int8"),
|
40 |
+
"blood_pressure_stability": datasets.Value("int8"),
|
41 |
+
"perceived_comfort": datasets.Value("int8"),
|
42 |
+
"decision": datasets.ClassLabel(num_classes=3, names=("discharge", "hospital floor", "intensive care")),
|
43 |
+
},
|
44 |
+
"post_operative_binary": {
|
45 |
+
"internal_temperature": datasets.Value("int8"),
|
46 |
+
"surface_temperature": datasets.Value("int8"),
|
47 |
+
"oxigen_saturation": datasets.Value("int8"),
|
48 |
+
"blood_pressure": datasets.Value("int8"),
|
49 |
+
"surface_temperature_stability": datasets.Value("int8"),
|
50 |
+
"internal_temperature_stability": datasets.Value("int8"),
|
51 |
+
"blood_pressure_stability": datasets.Value("int8"),
|
52 |
+
"perceived_comfort": datasets.Value("int8"),
|
53 |
+
"decision": datasets.ClassLabel(num_classes=2, names=("discharge", "don't discharge")),
|
54 |
+
}
|
55 |
+
}
|
56 |
+
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
|
57 |
+
|
58 |
+
|
59 |
+
class PostOperativeConfig(datasets.BuilderConfig):
|
60 |
+
def __init__(self, **kwargs):
|
61 |
+
super(PostOperativeConfig, self).__init__(version=VERSION, **kwargs)
|
62 |
+
self.features = features_per_config[kwargs["name"]]
|
63 |
+
|
64 |
+
|
65 |
+
class PostOperative(datasets.GeneratorBasedBuilder):
|
66 |
+
# dataset versions
|
67 |
+
DEFAULT_CONFIG = "post_operative"
|
68 |
+
BUILDER_CONFIGS = [
|
69 |
+
PostOperativeConfig(name="post_operative",
|
70 |
+
description="PostOperative for regression."),
|
71 |
+
PostOperativeConfig(name="post_operative_binary",
|
72 |
+
description="PostOperative for binary classification.")
|
73 |
+
]
|
74 |
+
|
75 |
+
|
76 |
+
def _info(self):
|
77 |
+
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
78 |
+
features=features_per_config[self.config.name])
|
79 |
+
|
80 |
+
return info
|
81 |
+
|
82 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
83 |
+
downloads = dl_manager.download_and_extract(urls_per_split)
|
84 |
+
|
85 |
+
return [
|
86 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
|
87 |
+
]
|
88 |
+
|
89 |
+
def _generate_examples(self, filepath: str):
|
90 |
+
data = pandas.read_csv(filepath)
|
91 |
+
data = self.preprocess(data)
|
92 |
+
|
93 |
+
for row_id, row in data.iterrows():
|
94 |
+
data_row = dict(row)
|
95 |
+
|
96 |
+
yield row_id, data_row
|
97 |
+
|
98 |
+
def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
|
99 |
+
if self.config.name == "post_operative_binary":
|
100 |
+
data["decision"] = data["decision"].apply(lambda x: 1 if x > 1 else 0)
|
101 |
+
|
102 |
+
for feature in _ENCODING_DICS:
|
103 |
+
encoding_function = partial(self.encode, feature)
|
104 |
+
data.loc[:, feature] = data[feature].apply(encoding_function)
|
105 |
+
|
106 |
+
data = data.reset_index()
|
107 |
+
data.drop("index", axis="columns", inplace=True)
|
108 |
+
|
109 |
+
return data[list(features_types_per_config[self.config.name].keys())]
|
110 |
+
|
111 |
+
def encode(self, feature, value):
|
112 |
+
if feature in _ENCODING_DICS:
|
113 |
+
return _ENCODING_DICS[feature][value]
|
114 |
+
raise ValueError(f"Unknown feature: {feature}")
|