Datasets:
Upload 3 files
Browse files- README.md +17 -0
- speeddating.csv +0 -0
- speeddating.py +237 -0
README.md
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
tags:
|
5 |
+
- speeddating
|
6 |
+
- tabular_classification
|
7 |
+
- binary_classification
|
8 |
+
pretty_name: Speed dating
|
9 |
+
size_categories:
|
10 |
+
- 1K<n<10K
|
11 |
+
task_categories: # Full list at https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts
|
12 |
+
- tabular-classification
|
13 |
+
configs:
|
14 |
+
- dating
|
15 |
+
---
|
16 |
+
# Speed dating
|
17 |
+
The [Speed dating dataset](https://www.openml.org/search?type=data&sort=nr_of_likes&status=active&id=40536) is cool.
|
speeddating.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
speeddating.py
ADDED
@@ -0,0 +1,237 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Speeddating 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 |
+
_BASE_FEATURE_NAMES = [
|
13 |
+
"dater_gender",
|
14 |
+
"dater_age",
|
15 |
+
"dated_age",
|
16 |
+
"age_difference",
|
17 |
+
"dater_race",
|
18 |
+
"dated_race",
|
19 |
+
"are_same_race",
|
20 |
+
"same_race_importance_for_dater",
|
21 |
+
"same_religion_importance_for_dater",
|
22 |
+
"attractiveness_importance_for_dated",
|
23 |
+
"sincerity_importance_for_dated",
|
24 |
+
"intelligence_importance_for_dated",
|
25 |
+
"humor_importance_for_dated",
|
26 |
+
"ambition_importance_for_dated",
|
27 |
+
"shared_interests_importance_for_dated",
|
28 |
+
"attractiveness_score_of_dater_from_dated",
|
29 |
+
"sincerity_score_of_dater_from_dated",
|
30 |
+
"intelligence_score_of_dater_from_dated",
|
31 |
+
"humor_score_of_dater_from_dated",
|
32 |
+
"ambition_score_of_dater_from_dated",
|
33 |
+
"shared_interests_score_of_dater_from_dated",
|
34 |
+
"attractiveness_importance_for_dater",
|
35 |
+
"sincerity_importance_for_dater",
|
36 |
+
"intelligence_importance_for_dater",
|
37 |
+
"humor_importance_for_dater",
|
38 |
+
"ambition_importance_for_dater",
|
39 |
+
"shared_interests_importance_for_dater",
|
40 |
+
"self_reported_attractiveness_of_dater",
|
41 |
+
"self_reported_sincerity_of_dater",
|
42 |
+
"self_reported_intelligence_of_dater",
|
43 |
+
"self_reported_humor_of_dater",
|
44 |
+
"self_reported_ambition_of_dater",
|
45 |
+
"reported_attractiveness_of_dated_from_dater",
|
46 |
+
"reported_sincerity_of_dated_from_dater",
|
47 |
+
"reported_intelligence_of_dated_from_dater",
|
48 |
+
"reported_humor_of_dated_from_dater",
|
49 |
+
"reported_ambition_of_dated_from_dater",
|
50 |
+
"reported_shared_interests_of_dated_from_dater",
|
51 |
+
"dater_interest_in_sports",
|
52 |
+
"dater_interest_in_tvsports",
|
53 |
+
"dater_interest_in_exercise",
|
54 |
+
"dater_interest_in_dining",
|
55 |
+
"dater_interest_in_museums",
|
56 |
+
"dater_interest_in_art",
|
57 |
+
"dater_interest_in_hiking",
|
58 |
+
"dater_interest_in_gaming",
|
59 |
+
"dater_interest_in_clubbing",
|
60 |
+
"dater_interest_in_reading",
|
61 |
+
"dater_interest_in_tv",
|
62 |
+
"dater_interest_in_theater",
|
63 |
+
"dater_interest_in_movies",
|
64 |
+
"dater_interest_in_concerts",
|
65 |
+
"dater_interest_in_music",
|
66 |
+
"dater_interest_in_shopping",
|
67 |
+
"dater_interest_in_yoga",
|
68 |
+
"interests_correlation",
|
69 |
+
"expected_satisfaction_of_dater",
|
70 |
+
"expected_number_of_likes_of_dater_from_20_people",
|
71 |
+
"expected_number_of_dates_for_dater",
|
72 |
+
"dater_liked_dated",
|
73 |
+
"probability_dated_wants_to_date",
|
74 |
+
"already_met_before",
|
75 |
+
"dater_wants_to_date",
|
76 |
+
"dated_wants_to_date",
|
77 |
+
"is_match"
|
78 |
+
]
|
79 |
+
|
80 |
+
DESCRIPTION = "Speed-dating dataset."
|
81 |
+
_HOMEPAGE = "https://www.openml.org/search?type=data&sort=nr_of_likes&status=active&id=40536"
|
82 |
+
_URLS = ("https://huggingface.co/datasets/mstz/speeddating/raw/main/speeddating.csv")
|
83 |
+
_CITATION = """"""
|
84 |
+
|
85 |
+
# Dataset info
|
86 |
+
urls_per_split = {
|
87 |
+
"train": "https://huggingface.co/datasets/mstz/speeddating/raw/main/speeddating.csv",
|
88 |
+
}
|
89 |
+
features_types_per_config = {
|
90 |
+
"dating": {
|
91 |
+
"dater_gender": datasets.Value("int8"),
|
92 |
+
"dater_age": datasets.Value("int8"),
|
93 |
+
"dated_age": datasets.Value("int8"),
|
94 |
+
"age_difference": datasets.Value("int8"),
|
95 |
+
"dater_race": datasets.Value("string"),
|
96 |
+
"dated_race": datasets.Value("string"),
|
97 |
+
"are_same_race": datasets.Value("int8"),
|
98 |
+
"same_race_importance_for_dater": datasets.Value("int8"),
|
99 |
+
"same_religion_importance_for_dater": datasets.Value("int8"),
|
100 |
+
"attractiveness_importance_for_dated": datasets.Value("int8"),
|
101 |
+
"sincerity_importance_for_dated": datasets.Value("int8"),
|
102 |
+
"intelligence_importance_for_dated": datasets.Value("int8"),
|
103 |
+
"humor_importance_for_dated": datasets.Value("int8"),
|
104 |
+
"ambition_importance_for_dated": datasets.Value("int8"),
|
105 |
+
"shared_interests_importance_for_dated": datasets.Value("int8"),
|
106 |
+
"attractiveness_score_of_dater_from_dated": datasets.Value("int8"),
|
107 |
+
"sincerity_score_of_dater_from_dated": datasets.Value("int8"),
|
108 |
+
"intelligence_score_of_dater_from_dated": datasets.Value("int8"),
|
109 |
+
"humor_score_of_dater_from_dated": datasets.Value("int8"),
|
110 |
+
"ambition_score_of_dater_from_dated": datasets.Value("int8"),
|
111 |
+
"shared_interests_score_of_dater_from_dated": datasets.Value("int8"),
|
112 |
+
"attractiveness_importance_for_dater": datasets.Value("int8"),
|
113 |
+
"sincerity_importance_for_dater": datasets.Value("int8"),
|
114 |
+
"intelligence_importance_for_dater": datasets.Value("int8"),
|
115 |
+
"humor_importance_for_dater": datasets.Value("int8"),
|
116 |
+
"ambition_importance_for_dater": datasets.Value("int8"),
|
117 |
+
"shared_interests_importance_for_dater": datasets.Value("int8"),
|
118 |
+
"self_reported_attractiveness_of_dater": datasets.Value("int8"),
|
119 |
+
"self_reported_sincerity_of_dater": datasets.Value("int8"),
|
120 |
+
"self_reported_intelligence_of_dater": datasets.Value("int8"),
|
121 |
+
"self_reported_humor_of_dater": datasets.Value("int8"),
|
122 |
+
"self_reported_ambition_of_dater": datasets.Value("int8"),
|
123 |
+
"reported_attractiveness_of_dated_from_dater": datasets.Value("int8"),
|
124 |
+
"reported_sincerity_of_dated_from_dater": datasets.Value("int8"),
|
125 |
+
"reported_intelligence_of_dated_from_dater": datasets.Value("int8"),
|
126 |
+
"reported_humor_of_dated_from_dater": datasets.Value("int8"),
|
127 |
+
"reported_ambition_of_dated_from_dater": datasets.Value("int8"),
|
128 |
+
"reported_shared_interests_of_dated_from_dater": datasets.Value("int8"),
|
129 |
+
"dater_interest_in_sports": datasets.Value("int8"),
|
130 |
+
"dater_interest_in_tvsports": datasets.Value("int8"),
|
131 |
+
"dater_interest_in_exercise": datasets.Value("int8"),
|
132 |
+
"dater_interest_in_dining": datasets.Value("int8"),
|
133 |
+
"dater_interest_in_museums": datasets.Value("int8"),
|
134 |
+
"dater_interest_in_art": datasets.Value("int8"),
|
135 |
+
"dater_interest_in_hiking": datasets.Value("int8"),
|
136 |
+
"dater_interest_in_gaming": datasets.Value("int8"),
|
137 |
+
"dater_interest_in_clubbing": datasets.Value("int8"),
|
138 |
+
"dater_interest_in_reading": datasets.Value("int8"),
|
139 |
+
"dater_interest_in_tv": datasets.Value("int8"),
|
140 |
+
"dater_interest_in_theater": datasets.Value("int8"),
|
141 |
+
"dater_interest_in_movies": datasets.Value("int8"),
|
142 |
+
"dater_interest_in_concerts": datasets.Value("int8"),
|
143 |
+
"dater_interest_in_music": datasets.Value("int8"),
|
144 |
+
"dater_interest_in_shopping": datasets.Value("int8"),
|
145 |
+
"dater_interest_in_yoga": datasets.Value("int8"),
|
146 |
+
"interests_correlation": datasets.Value("float16"),
|
147 |
+
"expected_satisfaction_of_dater": datasets.Value("int8"),
|
148 |
+
"expected_number_of_likes_of_dater_from_20_people": datasets.Value("int8"),
|
149 |
+
"expected_number_of_dates_for_dater": datasets.Value("int8"),
|
150 |
+
"dater_liked_dated": datasets.Value("int8"),
|
151 |
+
"probability_dated_wants_to_date": datasets.Value("int8"),
|
152 |
+
"already_met_before": datasets.Value("int8"),
|
153 |
+
"dater_wants_to_date": datasets.Value("int8"),
|
154 |
+
"dated_wants_to_date": datasets.Value("int8"),
|
155 |
+
"is_match": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
|
156 |
+
}
|
157 |
+
|
158 |
+
}
|
159 |
+
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
|
160 |
+
|
161 |
+
|
162 |
+
class SpeeddatingConfig(datasets.BuilderConfig):
|
163 |
+
def __init__(self, **kwargs):
|
164 |
+
super(SpeeddatingConfig, self).__init__(version=VERSION, **kwargs)
|
165 |
+
self.features = features_per_config[kwargs["name"]]
|
166 |
+
|
167 |
+
|
168 |
+
class Speeddating(datasets.GeneratorBasedBuilder):
|
169 |
+
# dataset versions
|
170 |
+
DEFAULT_CONFIG = "dating"
|
171 |
+
BUILDER_CONFIGS = [
|
172 |
+
SpeeddatingConfig(name="dating",
|
173 |
+
description="Binary classification."),
|
174 |
+
]
|
175 |
+
|
176 |
+
|
177 |
+
def _info(self):
|
178 |
+
if self.config.name not in features_per_config:
|
179 |
+
raise ValueError(f"Unknown configuration: {self.config.name}")
|
180 |
+
|
181 |
+
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
182 |
+
features=features_per_config[self.config.name])
|
183 |
+
|
184 |
+
return info
|
185 |
+
|
186 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
187 |
+
downloads = dl_manager.download_and_extract(urls_per_split)
|
188 |
+
|
189 |
+
return [
|
190 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
|
191 |
+
]
|
192 |
+
|
193 |
+
def _generate_examples(self, filepath: str):
|
194 |
+
data = pandas.read_csv(filepath)
|
195 |
+
data = self.preprocess(data, config=self.config.name)
|
196 |
+
|
197 |
+
for row_id, row in data.iterrows():
|
198 |
+
data_row = dict(row)
|
199 |
+
|
200 |
+
yield row_id, data_row
|
201 |
+
|
202 |
+
def preprocess(self, data: pandas.DataFrame, config: str = "dating") -> pandas.DataFrame:
|
203 |
+
data.loc[data.race == "?", "race"] = "unknown"
|
204 |
+
data.loc[data.race == "Asian/Pacific Islander/Asian-American", "race"] = "asian"
|
205 |
+
data.loc[data.race == "European/Caucasian-American", "race"] = "caucasian"
|
206 |
+
data.loc[data.race == "Other", "race"] = "other"
|
207 |
+
data.loc[data.race == "Latino/Hispanic American", "race"] = "hispanic"
|
208 |
+
data.loc[data.race == "Black/African American", "race"] = "african-american"
|
209 |
+
|
210 |
+
sex_transform = partial(self.encoding_dics, "sex")
|
211 |
+
data.loc[:, "sex"] = data.sex.apply(sex_transform)
|
212 |
+
|
213 |
+
data.drop("has_null", axis="columns", inplace=True)
|
214 |
+
data.drop("field", axis="columns", inplace=True)
|
215 |
+
|
216 |
+
data = data[data.age != "?"]
|
217 |
+
data = data[data.importance_same_race != "?"]
|
218 |
+
data = data[data.pref_o_attractive != "?"]
|
219 |
+
data = data[data.pref_o_sincere != "?"]
|
220 |
+
data = data[data.interests_correlate != "?"]
|
221 |
+
|
222 |
+
data.columns = _BASE_FEATURE_NAMES
|
223 |
+
|
224 |
+
if config == "dating":
|
225 |
+
return data
|
226 |
+
else:
|
227 |
+
raise ValueError(f"Unknown config: {config}")
|
228 |
+
|
229 |
+
def encoding_dics(feature, value):
|
230 |
+
match feature:
|
231 |
+
case "sex":
|
232 |
+
return {
|
233 |
+
"female": 0,
|
234 |
+
"male": 1
|
235 |
+
}
|
236 |
+
case _:
|
237 |
+
raise ValueError(f"Unknown feature: {feature}")
|