mstz commited on
Commit
20b6bd6
·
1 Parent(s): 8314dbb

Upload 3 files

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. README.md +18 -1
  3. p53.data +3 -0
  4. p53.py +93 -0
.gitattributes CHANGED
@@ -52,3 +52,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
55
+ p53.data filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,20 @@
1
  ---
2
- license: cc-by-4.0
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - p53
6
+ - tabular_classification
7
+ - binary_classification
8
+ pretty_name: P53
9
+ task_categories: # Full list at https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts
10
+ - tabular-classification
11
+ configs:
12
+ - p53
13
  ---
14
+ # P53
15
+ The [P53 dataset](https://archive-beta.ics.uci.edu/dataset/170/p53) from the [UCI repository](https://archive-beta.ics.uci.edu/).
16
+
17
+ # Configurations and tasks
18
+ | **Configuration** | **Task** | **Description** |
19
+ |-----------------------|---------------------------|-------------------------|
20
+ | p53 | Binary classification.| |
p53.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b86a54915a56eef6b256c8567b8e2cd1127b2137f1cd59c4437af80d99d729f7
3
+ size 1157416390
p53.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """P53 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
+ "class": {
15
+ "inactive": 0,
16
+ "active": 1
17
+ }
18
+ }
19
+
20
+ DESCRIPTION = "P53 dataset."
21
+ _HOMEPAGE = "https://archive-beta.ics.uci.edu/dataset/170/p53"
22
+ _URLS = ("https://archive-beta.ics.uci.edu/dataset/170/p53")
23
+ _CITATION = """
24
+ @misc{misc_p53_mutants_188,
25
+ author = {Lathrop,Richard},
26
+ title = {{p53 Mutants}},
27
+ year = {2010},
28
+ howpublished = {UCI Machine Learning Repository},
29
+ note = {{DOI}: \\url{10.24432/C5T89H}}
30
+ }
31
+ """
32
+
33
+ # Dataset info
34
+ urls_per_split = {
35
+ "train": "https://huggingface.co/datasets/mstz/p53/resolve/main/p53.data"
36
+ }
37
+ features_types_per_config = {
38
+ "p53": {f"feature_{i}": datasets.Value("float64") for i in range(5408)}
39
+ }
40
+ features_types_per_config["p53"]["class"] = datasets.ClassLabel(num_classes=2)
41
+ features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
42
+
43
+
44
+ class P53Config(datasets.BuilderConfig):
45
+ def __init__(self, **kwargs):
46
+ super(P53Config, self).__init__(version=VERSION, **kwargs)
47
+ self.features = features_per_config[kwargs["name"]]
48
+
49
+
50
+ class P53(datasets.GeneratorBasedBuilder):
51
+ # dataset versions
52
+ DEFAULT_CONFIG = "p53"
53
+ BUILDER_CONFIGS = [
54
+ P53Config(name="p53", description="P53 for binary classification.")
55
+ ]
56
+
57
+
58
+ def _info(self):
59
+ info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
60
+ features=features_per_config[self.config.name])
61
+
62
+ return info
63
+
64
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
65
+ downloads = dl_manager.download_and_extract(urls_per_split)
66
+
67
+ return [
68
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
69
+ ]
70
+
71
+ def _generate_examples(self, filepath: str):
72
+ data = pandas.read_csv(filepath, header=None)
73
+ data = self.preprocess(data)
74
+
75
+ for row_id, row in data.iterrows():
76
+ data_row = dict(row)
77
+
78
+ yield row_id, data_row
79
+
80
+ def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
81
+ for feature in _ENCODING_DICS:
82
+ encoding_function = partial(self.encode, feature)
83
+ data.loc[:, feature] = data[feature].apply(encoding_function)
84
+
85
+ for feature in list(data.colums)[:-1]:
86
+ data[data[feature] == "?", feature] = data[feature].mean()
87
+
88
+ return data[list(features_types_per_config[self.config.name].keys())]
89
+
90
+ def encode(self, feature, value):
91
+ if feature in _ENCODING_DICS:
92
+ return _ENCODING_DICS[feature][value]
93
+ raise ValueError(f"Unknown feature: {feature}")