Datasets:
Update student_performance.py
Browse files- student_performance.py +11 -9
student_performance.py
CHANGED
@@ -59,31 +59,31 @@ features_types_per_config = {
|
|
59 |
"encoded_value": datasets.Value("int64")
|
60 |
},
|
61 |
"math": {
|
62 |
-
"
|
63 |
"ethnicity": datasets.Value("string"),
|
64 |
"parental_level_of_education": datasets.Value("int8"),
|
65 |
-
"has_standard_lunch": datasets.Value("
|
66 |
-
"has_completed_preparation_test": datasets.Value("
|
67 |
"reading_score": datasets.Value("int64"),
|
68 |
"writing_score": datasets.Value("int64"),
|
69 |
"has_passed_math_exam": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
|
70 |
},
|
71 |
"writing": {
|
72 |
-
"
|
73 |
"ethnicity": datasets.Value("string"),
|
74 |
"parental_level_of_education": datasets.Value("int8"),
|
75 |
-
"has_standard_lunch": datasets.Value("
|
76 |
-
"has_completed_preparation_test": datasets.Value("
|
77 |
"reading_score": datasets.Value("int64"),
|
78 |
"math_score": datasets.Value("int64"),
|
79 |
"has_passed_writing_exam": datasets.ClassLabel(num_classes=2, names=("no", "yes")),
|
80 |
},
|
81 |
"reading": {
|
82 |
-
"
|
83 |
"ethnicity": datasets.Value("string"),
|
84 |
"parental_level_of_education": datasets.Value("int8"),
|
85 |
-
"has_standard_lunch": datasets.Value("
|
86 |
-
"has_completed_preparation_test": datasets.Value("
|
87 |
"writing_score": datasets.Value("int64"),
|
88 |
"math_score": datasets.Value("int64"),
|
89 |
"has_passed_reading_exam": datasets.ClassLabel(num_classes=2, names=("no", "yes")),
|
@@ -148,6 +148,8 @@ class StudentPerformance(datasets.GeneratorBasedBuilder):
|
|
148 |
for feature in _ENCODING_DICS:
|
149 |
encoding_function = partial(self.encode, feature)
|
150 |
data.loc[:, feature] = data[feature].apply(encoding_function)
|
|
|
|
|
151 |
|
152 |
if config == "math":
|
153 |
data = data.rename(columns={"math_score": "has_passed_math_exam"})
|
|
|
59 |
"encoded_value": datasets.Value("int64")
|
60 |
},
|
61 |
"math": {
|
62 |
+
"is_male": datasets.Value("bool"),
|
63 |
"ethnicity": datasets.Value("string"),
|
64 |
"parental_level_of_education": datasets.Value("int8"),
|
65 |
+
"has_standard_lunch": datasets.Value("bool"),
|
66 |
+
"has_completed_preparation_test": datasets.Value("bool"),
|
67 |
"reading_score": datasets.Value("int64"),
|
68 |
"writing_score": datasets.Value("int64"),
|
69 |
"has_passed_math_exam": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
|
70 |
},
|
71 |
"writing": {
|
72 |
+
"is_male": datasets.Value("bool"),
|
73 |
"ethnicity": datasets.Value("string"),
|
74 |
"parental_level_of_education": datasets.Value("int8"),
|
75 |
+
"has_standard_lunch": datasets.Value("bool"),
|
76 |
+
"has_completed_preparation_test": datasets.Value("bool"),
|
77 |
"reading_score": datasets.Value("int64"),
|
78 |
"math_score": datasets.Value("int64"),
|
79 |
"has_passed_writing_exam": datasets.ClassLabel(num_classes=2, names=("no", "yes")),
|
80 |
},
|
81 |
"reading": {
|
82 |
+
"is_male": datasets.Value("bool"),
|
83 |
"ethnicity": datasets.Value("string"),
|
84 |
"parental_level_of_education": datasets.Value("int8"),
|
85 |
+
"has_standard_lunch": datasets.Value("bool"),
|
86 |
+
"has_completed_preparation_test": datasets.Value("bool"),
|
87 |
"writing_score": datasets.Value("int64"),
|
88 |
"math_score": datasets.Value("int64"),
|
89 |
"has_passed_reading_exam": datasets.ClassLabel(num_classes=2, names=("no", "yes")),
|
|
|
148 |
for feature in _ENCODING_DICS:
|
149 |
encoding_function = partial(self.encode, feature)
|
150 |
data.loc[:, feature] = data[feature].apply(encoding_function)
|
151 |
+
data = data.rename(columns={"sex": "is_male"})
|
152 |
+
data = data.astype({"is_male": "bool", "has_standard_lunch": "bool", "has_completed_preparation_test": "bool"})
|
153 |
|
154 |
if config == "math":
|
155 |
data = data.rename(columns={"math_score": "has_passed_math_exam"})
|