Datasets:
Update speeddating.py
Browse files- speeddating.py +12 -16
speeddating.py
CHANGED
@@ -88,13 +88,13 @@ urls_per_split = {
|
|
88 |
}
|
89 |
features_types_per_config = {
|
90 |
"dating": {
|
91 |
-
"is_dater_male": datasets.Value("
|
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("
|
98 |
"same_race_importance_for_dater": datasets.Value("float64"),
|
99 |
"same_religion_importance_for_dater": datasets.Value("float64"),
|
100 |
"attractiveness_importance_for_dated": datasets.Value("float64"),
|
@@ -149,9 +149,9 @@ features_types_per_config = {
|
|
149 |
"expected_number_of_dates_for_dater": datasets.Value("int8"),
|
150 |
"dater_liked_dated": datasets.Value("float64"),
|
151 |
"probability_dated_wants_to_date": datasets.Value("float64"),
|
152 |
-
"already_met_before": datasets.Value("
|
153 |
-
"dater_wants_to_date": datasets.Value("
|
154 |
-
"dated_wants_to_date": datasets.Value("
|
155 |
"is_match": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
|
156 |
}
|
157 |
|
@@ -175,9 +175,6 @@ class Speeddating(datasets.GeneratorBasedBuilder):
|
|
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 |
|
@@ -191,16 +188,13 @@ class Speeddating(datasets.GeneratorBasedBuilder):
|
|
191 |
]
|
192 |
|
193 |
def _generate_examples(self, filepath: str):
|
194 |
-
|
195 |
-
|
196 |
-
data = self.preprocess(data, config=self.config.name)
|
197 |
|
198 |
-
|
199 |
-
|
200 |
|
201 |
-
|
202 |
-
else:
|
203 |
-
raise ValueError(f"Unknown config: {self.config.name}")
|
204 |
|
205 |
def preprocess(self, data: pandas.DataFrame, config: str = "dating") -> pandas.DataFrame:
|
206 |
data.loc[data.race == "?", "race"] = "unknown"
|
@@ -316,5 +310,7 @@ class Speeddating(datasets.GeneratorBasedBuilder):
|
|
316 |
data = data[data.met != "?"]
|
317 |
|
318 |
data.columns = _BASE_FEATURE_NAMES
|
|
|
|
|
319 |
|
320 |
return data
|
|
|
88 |
}
|
89 |
features_types_per_config = {
|
90 |
"dating": {
|
91 |
+
"is_dater_male": datasets.Value("bool"),
|
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("bool"),
|
98 |
"same_race_importance_for_dater": datasets.Value("float64"),
|
99 |
"same_religion_importance_for_dater": datasets.Value("float64"),
|
100 |
"attractiveness_importance_for_dated": datasets.Value("float64"),
|
|
|
149 |
"expected_number_of_dates_for_dater": datasets.Value("int8"),
|
150 |
"dater_liked_dated": datasets.Value("float64"),
|
151 |
"probability_dated_wants_to_date": datasets.Value("float64"),
|
152 |
+
"already_met_before": datasets.Value("bool"),
|
153 |
+
"dater_wants_to_date": datasets.Value("bool"),
|
154 |
+
"dated_wants_to_date": datasets.Value("bool"),
|
155 |
"is_match": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
|
156 |
}
|
157 |
|
|
|
175 |
|
176 |
|
177 |
def _info(self):
|
|
|
|
|
|
|
178 |
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
179 |
features=features_per_config[self.config.name])
|
180 |
|
|
|
188 |
]
|
189 |
|
190 |
def _generate_examples(self, filepath: str):
|
191 |
+
data = pandas.read_csv(filepath)
|
192 |
+
data = self.preprocess(data, config=self.config.name)
|
|
|
193 |
|
194 |
+
for row_id, row in data.iterrows():
|
195 |
+
data_row = dict(row)
|
196 |
|
197 |
+
yield row_id, data_row
|
|
|
|
|
198 |
|
199 |
def preprocess(self, data: pandas.DataFrame, config: str = "dating") -> pandas.DataFrame:
|
200 |
data.loc[data.race == "?", "race"] = "unknown"
|
|
|
310 |
data = data[data.met != "?"]
|
311 |
|
312 |
data.columns = _BASE_FEATURE_NAMES
|
313 |
+
data = data.astype({"is_dater_male": "bool", "are_same_race": "bool", "already_met_before": "bool",
|
314 |
+
"dater_wants_to_date": "bool", "dated_wants_to_date": "bool"})
|
315 |
|
316 |
return data
|