mstz commited on
Commit
ded984d
1 Parent(s): 383ff37

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +29 -1
  2. chess_rock_vs_pawn.py +143 -0
  3. kr-vs-kp.data +0 -0
  4. kr-vs-kp.names +66 -0
README.md CHANGED
@@ -1,3 +1,31 @@
1
  ---
2
- license: cc
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - chess
6
+ - tabular_classification
7
+ - binary_classification
8
+ - multiclass_classification
9
+ pretty_name: Adult
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
+ - chess
16
  ---
17
+ # Adult
18
+ The [Adult dataset](https://archive.ics.uci.edu/ml/datasets/Adult) from the [UCI ML repository](https://archive.ics.uci.edu/ml/datasets).
19
+ Census dataset including personal characteristic of a person, and their income threshold.
20
+
21
+ # Configurations and tasks
22
+ | **Configuration** | **Task** | **Description** |
23
+ |-------------------|---------------------------|--------------------------|
24
+ | chess | Binary classification | Can the white piece win? |
25
+
26
+ # Usage
27
+ ```python
28
+ from datasets import load_dataset
29
+
30
+ dataset = load_dataset("mstz/chess", "chess")["train"]
31
+ ```
chess_rock_vs_pawn.py ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Chess"""
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
+ "bkblk",
13
+ "bknwy",
14
+ "bkon8",
15
+ "bkona",
16
+ "bkspr",
17
+ "bkxbq",
18
+ "bkxcr",
19
+ "bkxwp",
20
+ "blxwp",
21
+ "bxqsq",
22
+ "cntxt",
23
+ "dsopp",
24
+ "dwipd",
25
+ "hdchk",
26
+ "katri",
27
+ "mulch",
28
+ "qxmsq",
29
+ "r2ar8",
30
+ "reskd",
31
+ "reskr",
32
+ "rimmx",
33
+ "rkxwp",
34
+ "rxmsq",
35
+ "simpl",
36
+ "skach",
37
+ "skewr",
38
+ "skrxp",
39
+ "spcop",
40
+ "stlmt",
41
+ "thrsk",
42
+ "wkcti",
43
+ "wkna8",
44
+ "wknck",
45
+ "wkovl",
46
+ "wkpos",
47
+ "white_wins"
48
+ ]
49
+
50
+ DESCRIPTION = "Chess dataset from the UCI ML repository."
51
+ _HOMEPAGE = "https://archive.ics.uci.edu/ml/datasets/Chess"
52
+ _URLS = ("https://huggingface.co/datasets/mstz/chess/raw/chess.csv")
53
+ _CITATION = """
54
+ @misc{misc_chess_(king-rook_vs._king-pawn)_22,
55
+ title = {{Chess (King-Rook vs. King-Pawn)}},
56
+ year = {1989},
57
+ howpublished = {UCI Machine Learning Repository},
58
+ note = {{DOI}: \\url{10.24432/C5DK5C}}
59
+ }"""
60
+
61
+ # Dataset info
62
+ urls_per_split = {
63
+ "train": "https://huggingface.co/datasets/mstz/chess/raw/main/kr-vs-kp.data"
64
+ }
65
+ features_types_per_config = {
66
+ "chess": {
67
+ "bkblk": datasets.Value("string"),
68
+ "bknwy": datasets.Value("string"),
69
+ "bkon8": datasets.Value("string"),
70
+ "bkona": datasets.Value("string"),
71
+ "bkspr": datasets.Value("string"),
72
+ "bkxbq": datasets.Value("string"),
73
+ "bkxcr": datasets.Value("string"),
74
+ "bkxwp": datasets.Value("string"),
75
+ "blxwp": datasets.Value("string"),
76
+ "bxqsq": datasets.Value("string"),
77
+ "cntxt": datasets.Value("string"),
78
+ "dsopp": datasets.Value("string"),
79
+ "dwipd": datasets.Value("string"),
80
+ "hdchk": datasets.Value("string"),
81
+ "katri": datasets.Value("string"),
82
+ "mulch": datasets.Value("string"),
83
+ "qxmsq": datasets.Value("string"),
84
+ "r2ar8": datasets.Value("string"),
85
+ "reskd": datasets.Value("string"),
86
+ "reskr": datasets.Value("string"),
87
+ "rimmx": datasets.Value("string"),
88
+ "rkxwp": datasets.Value("string"),
89
+ "rxmsq": datasets.Value("string"),
90
+ "simpl": datasets.Value("string"),
91
+ "skach": datasets.Value("string"),
92
+ "skewr": datasets.Value("string"),
93
+ "skrxp": datasets.Value("string"),
94
+ "spcop": datasets.Value("string"),
95
+ "stlmt": datasets.Value("string"),
96
+ "thrsk": datasets.Value("string"),
97
+ "wkcti": datasets.Value("string"),
98
+ "wkna8": datasets.Value("string"),
99
+ "wknck": datasets.Value("string"),
100
+ "wkovl": datasets.Value("string"),
101
+ "wkpos": datasets.Value("string"),
102
+ "white_wins": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
103
+ }
104
+ }
105
+ features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
106
+
107
+
108
+ class ChessConfig(datasets.BuilderConfig):
109
+ def __init__(self, **kwargs):
110
+ super(ChessConfig, self).__init__(version=VERSION, **kwargs)
111
+ self.features = features_per_config[kwargs["name"]]
112
+
113
+
114
+ class Chess(datasets.GeneratorBasedBuilder):
115
+ # dataset versions
116
+ DEFAULT_CONFIG = "chess"
117
+ BUILDER_CONFIGS = [
118
+ ChessConfig(name="chess",
119
+ description="Chess for binary classification.")
120
+ ]
121
+
122
+
123
+ def _info(self):
124
+ info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
125
+ features=features_per_config[self.config.name])
126
+
127
+ return info
128
+
129
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
130
+ downloads = dl_manager.download_and_extract(urls_per_split)
131
+
132
+ return [
133
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]})
134
+ ]
135
+
136
+ def _generate_examples(self, filepath: str):
137
+ data = pandas.read_csv(filepath)
138
+ data = self.preprocess(data, config=self.config.name)
139
+
140
+ for row_id, row in data.iterrows():
141
+ data_row = dict(row)
142
+
143
+ yield row_id, data_row
kr-vs-kp.data ADDED
The diff for this file is too large to render. See raw diff
 
kr-vs-kp.names ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1. Title: Chess End-Game -- King+Rook versus King+Pawn on a7
2
+ (usually abbreviated KRKPA7). The pawn on a7 means it is one square
3
+ away from queening. It is the King+Rook's side (white) to move.
4
+
5
+ 2. Sources:
6
+ (a) Database originally generated and described by Alen Shapiro.
7
+ (b) Donor/Coder: Rob Holte (holte@uottawa.bitnet). The database
8
+ was supplied to Holte by Peter Clark of the Turing Institute
9
+ in Glasgow (pete@turing.ac.uk).
10
+ (c) Date: 1 August 1989
11
+
12
+ 3. Past Usage:
13
+ - Alen D. Shapiro (1983,1987), "Structured Induction in Expert Systems",
14
+ Addison-Wesley. This book is based on Shapiro's Ph.D. thesis (1983)
15
+ at the University of Edinburgh entitled "The Role of Structured
16
+ Induction in Expert Systems".
17
+ - Stephen Muggleton (1987), "Structuring Knowledge by Asking Questions",
18
+ pp.218-229 in "Progress in Machine Learning", edited by I. Bratko
19
+ and Nada Lavrac, Sigma Press, Wilmslow, England SK9 5BB.
20
+ - Robert C. Holte, Liane Acker, and Bruce W. Porter (1989),
21
+ "Concept Learning and the Problem of Small Disjuncts",
22
+ Proceedings of IJCAI. Also available as technical report AI89-106,
23
+ Computer Sciences Department, University of Texas at Austin,
24
+ Austin, Texas 78712.
25
+
26
+ 4. Relevant Information:
27
+ The dataset format is described below. Note: the format of this
28
+ database was modified on 2/26/90 to conform with the format of all
29
+ the other databases in the UCI repository of machine learning databases.
30
+
31
+ 5. Number of Instances: 3196 total
32
+
33
+ 6. Number of Attributes: 36
34
+
35
+ 7. Attribute Summaries:
36
+ Classes (2): -- White-can-win ("won") and White-cannot-win ("nowin").
37
+ I believe that White is deemed to be unable to win if the Black pawn
38
+ can safely advance.
39
+ Attributes: see Shapiro's book.
40
+
41
+ 8. Missing Attributes: -- none
42
+
43
+ 9. Class Distribution:
44
+ In 1669 of the positions (52%), White can win.
45
+ In 1527 of the positions (48%), White cannot win.
46
+
47
+ The format for instances in this database is a sequence of 37 attribute values.
48
+ Each instance is a board-descriptions for this chess endgame. The first
49
+ 36 attributes describe the board. The last (37th) attribute is the
50
+ classification: "win" or "nowin". There are 0 missing values.
51
+ A typical board-description is
52
+
53
+ f,f,f,f,f,f,f,f,f,f,f,f,l,f,n,f,f,t,f,f,f,f,f,f,f,t,f,f,f,f,f,f,f,t,t,n,won
54
+
55
+ The names of the features do not appear in the board-descriptions.
56
+ Instead, each feature correponds to a particular position in the
57
+ feature-value list. For example, the head of this list is the value
58
+ for the feature "bkblk". The following is the list of features, in
59
+ the order in which their values appear in the feature-value list:
60
+
61
+ [bkblk,bknwy,bkon8,bkona,bkspr,bkxbq,bkxcr,bkxwp,blxwp,bxqsq,cntxt,dsopp,dwipd,
62
+ hdchk,katri,mulch,qxmsq,r2ar8,reskd,reskr,rimmx,rkxwp,rxmsq,simpl,skach,skewr,
63
+ skrxp,spcop,stlmt,thrsk,wkcti,wkna8,wknck,wkovl,wkpos,wtoeg]
64
+
65
+ In the file, there is one instance (board position) per line.
66
+