mstz commited on
Commit
831a492
1 Parent(s): f786df2

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +54 -1
  2. acute inflammation.py +99 -0
  3. diagnosis.data +0 -0
README.md CHANGED
@@ -1,3 +1,56 @@
1
  ---
2
- license: cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - adult
6
+ - tabular_classification
7
+ - binary_classification
8
+ - multiclass_classification
9
+ pretty_name: Adult
10
+ size_categories:
11
+ - 10K<n<100K
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
+ - encoding
16
+ - income
17
+ - income-no race
18
+ - race
19
  ---
20
+ # Adult
21
+ The [Adult dataset](https://archive.ics.uci.edu/ml/datasets/Adult) from the [UCI ML repository](https://archive.ics.uci.edu/ml/datasets).
22
+ Census dataset including personal characteristic of a person, and their income threshold.
23
+
24
+ # Configurations and tasks
25
+ | **Configuration** | **Task** | Description |
26
+ |-------------------|---------------------------|---------------------------------------------------------------|
27
+ | encoding | | Encoding dictionary |
28
+ | income | Binary classification | Classify the person's income as over or under the threshold. |
29
+ | income-no race | Binary classification | As `income`, but the `race` feature is removed. |
30
+ | race | Multiclass classification | Predict the race of the individual. |
31
+
32
+ # Usage
33
+ ```
34
+ from datasets import load_dataset
35
+ from sklearn.tree import DecisionTreeClassifier
36
+
37
+ dataset = load_dataset("mstz/adult", "income")["train"]
38
+ ```
39
+
40
+ # Features
41
+ |**Feature** |**Type** | **Description** |
42
+ |-------------------|-----------|-----------------------------------------------------------|
43
+ |`age` |`[int64]` | Age of the person |
44
+ |`capital_gain` |`[float64]`| Capital gained by the person |
45
+ |`capital_loss` |`[float64]`| Capital lost by the person |
46
+ |`education` |`[int8]` | Education level: the higher, the more educated the person |
47
+ |`final_weight` |`[int64]` | |
48
+ |`hours_per_week` |`[int64]` | Hours worked per week |
49
+ |`marital_status` |`[string]` | Marital status of the person |
50
+ |`native_country` |`[string]` | Native country of the person |
51
+ |`occupation` |`[string]` | Job of the person |
52
+ |`race` |`[string]` | Race of the person |
53
+ |`relationship` |`[string]` | |
54
+ |`sex` |`[int8]` | Sex of the person |
55
+ |`workclass` |`[string]` | Type of job of the person |
56
+ |`over_threshold` |`int8` |`1` for income `>= 50k$`, `0` otherwise |
acute inflammation.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Acute_Inflamamtion"""
2
+
3
+ from typing import List
4
+
5
+ import datasets
6
+
7
+ import pandas
8
+
9
+
10
+ VERSION = datasets.Version("1.0.0")
11
+ _BASE_FEATURE_NAMES = [
12
+ "temperature",
13
+ "has_nausea",
14
+ "has_lumbar_pain",
15
+ "has_urine_pushing",
16
+ "has_micturition_pains",
17
+ "has_burnt_urethra",
18
+ "has_inflammed_bladder",
19
+ "has_nephritis_of_renal_pelvis"
20
+ ]
21
+
22
+ DESCRIPTION = "Acute_Inflamamtion dataset from the UCI ML repository."
23
+ _HOMEPAGE = "https://archive.ics.uci.edu/ml/datasets/Acute_Inflamamtion"
24
+ _URLS = ("https://huggingface.co/datasets/mstz/acute_inflamamtion/raw/diagnosis.data")
25
+ _CITATION = """
26
+ @misc{misc_acute_inflammations_184,
27
+ author = {Czerniak,Jacek},
28
+ title = {{Acute Inflammations}},
29
+ year = {2009},
30
+ howpublished = {UCI Machine Learning Repository},
31
+ note = {{DOI}: \\url{10.24432/C5V59S}}
32
+ }"""
33
+
34
+ # Dataset info
35
+ urls_per_split = {
36
+ "train": "https://huggingface.co/datasets/mstz/acute_inflamamtion/raw/main/diagnosis.data"
37
+ }
38
+ features_types_per_config = {
39
+ "inflammation": {
40
+ "temperature": datasets.Value("float64"),
41
+ "has_nausea": datasets.Value("bool"),
42
+ "has_lumbar_pain": datasets.Value("bool"),
43
+ "has_urine_pushing": datasets.Value("bool"),
44
+ "has_micturition_pains": datasets.Value("bool"),
45
+ "has_burnt_urethra": datasets.Value("bool"),
46
+ "has_inflammed_bladder": datasets.Value("bool"),
47
+ "has_nephritis_of_renal_pelvis": datasets.Value("int8")
48
+ }
49
+ }
50
+ features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
51
+
52
+
53
+ class Acute_InflamamtionConfig(datasets.BuilderConfig):
54
+ def __init__(self, **kwargs):
55
+ super(Acute_InflamamtionConfig, self).__init__(version=VERSION, **kwargs)
56
+ self.features = features_per_config[kwargs["name"]]
57
+
58
+
59
+ class Acute_Inflamamtion(datasets.GeneratorBasedBuilder):
60
+ # dataset versions
61
+ DEFAULT_CONFIG = "inflammation"
62
+ BUILDER_CONFIGS = [
63
+ Acute_InflamamtionConfig(name="inflammation",
64
+ description="Binary classification of inflammation.")
65
+ ]
66
+
67
+
68
+ def _info(self):
69
+ info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
70
+ features=features_per_config[self.config.name])
71
+
72
+ return info
73
+
74
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
75
+ downloads = dl_manager.download_and_extract(urls_per_split)
76
+
77
+ return [
78
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]})
79
+ ]
80
+
81
+ def _generate_examples(self, filepath: str):
82
+ data = pandas.read_csv(filepath)
83
+ data = self.preprocess(data, config=self.config.name)
84
+
85
+ for row_id, row in data.iterrows():
86
+ data_row = dict(row)
87
+
88
+ yield row_id, data_row
89
+
90
+ def preprocess(self, data: pandas.DataFrame, config: str = DEFAULT_CONFIG) -> pandas.DataFrame:
91
+ data.columns = _BASE_FEATURE_NAMES
92
+ boolean_features = ["has_nausea", "has_lumbar_pain", "has_urine_pushing",
93
+ "has_micturition_pains", "has_burnt_urethra", "has_inflammed_bladder"]
94
+ for f in boolean_features:
95
+ data.loc[:, f] = data[f].apply(lambda x: True if x == "yes" else False)
96
+
97
+ data = data.astype({f: "bool" for f in boolean_features})
98
+
99
+ return data
diagnosis.data ADDED
Binary file (7.28 kB). View file