mstz commited on
Commit
56bbaf9
1 Parent(s): 7341b63

Update abalone.py

Browse files
Files changed (1) hide show
  1. abalone.py +17 -2
abalone.py CHANGED
@@ -58,6 +58,17 @@ features_types_per_config = {
58
  "viscera_weight": datasets.Value("float64"),
59
  "shell_weight": datasets.Value("float64"),
60
  "number_of_rings": datasets.Value("int8")
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
  }
63
  features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
@@ -73,8 +84,8 @@ class Abalone(datasets.GeneratorBasedBuilder):
73
  # dataset versions
74
  DEFAULT_CONFIG = "abalone"
75
  BUILDER_CONFIGS = [
76
- AbaloneConfig(name="abalone",
77
- description="Abalone for regression."),
78
  ]
79
 
80
 
@@ -95,6 +106,10 @@ class Abalone(datasets.GeneratorBasedBuilder):
95
  data = pandas.read_csv(filepath, header=None)
96
  data.columns = _BASE_FEATURE_NAMES
97
 
 
 
 
 
98
  for row_id, row in data.iterrows():
99
  data_row = dict(row)
100
 
 
58
  "viscera_weight": datasets.Value("float64"),
59
  "shell_weight": datasets.Value("float64"),
60
  "number_of_rings": datasets.Value("int8")
61
+ },
62
+ "binary": {
63
+ "sex": datasets.Value("string"),
64
+ "length": datasets.Value("float64"),
65
+ "diameter": datasets.Value("float64"),
66
+ "height": datasets.Value("float64"),
67
+ "whole_weight": datasets.Value("float64"),
68
+ "shucked_weight": datasets.Value("float64"),
69
+ "viscera_weight": datasets.Value("float64"),
70
+ "shell_weight": datasets.Value("float64"),
71
+ "is_old": datasets.ClassLabel(num_classes=2)
72
  }
73
  }
74
  features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
 
84
  # dataset versions
85
  DEFAULT_CONFIG = "abalone"
86
  BUILDER_CONFIGS = [
87
+ AbaloneConfig(name="abalone", description="Abalone for regression."),
88
+ AbaloneConfig(name="binary", description="Abalone for binary classification."),
89
  ]
90
 
91
 
 
106
  data = pandas.read_csv(filepath, header=None)
107
  data.columns = _BASE_FEATURE_NAMES
108
 
109
+ if self.config.name == "binary":
110
+ data = data.rename(columns={"number_of_rings": "is_old"})
111
+ data["is_old"] = data["is_old"].apply(lambda x: 1 if x > 9 else 0)
112
+
113
  for row_id, row in data.iterrows():
114
  data_row = dict(row)
115