mastergopote44 commited on
Commit
f652860
1 Parent(s): 4dcaccd
Files changed (1) hide show
  1. Long-Term-Care-Aggregated-Data.py +31 -41
Long-Term-Care-Aggregated-Data.py CHANGED
@@ -121,37 +121,27 @@ class LongTermCareAggregatedData(datasets.GeneratorBasedBuilder):
121
  citation="Please cite this dataset as: Society of Actuaries (SOA). (2020). Long Term Care Insurance Aggregate Experience Data, 2000-2016."
122
  )
123
 
124
- def _split_generators(self, dl_manager):
125
 
 
126
  downloaded_files = dl_manager.download(_URLS)
127
 
 
 
 
 
128
  return [
129
  datasets.SplitGenerator(
130
- name="train_incidence",
131
- gen_kwargs={
132
- "data_file": downloaded_files["train_incidence"],
133
- "split": "incidence",
134
- },
135
- ),
136
- datasets.SplitGenerator(
137
- name="validation_incidence",
138
- gen_kwargs={
139
- "data_file": downloaded_files["validation_incidence"],
140
- "split": "incidence",
141
- },
142
- ),
143
- datasets.SplitGenerator(
144
- name="train_termination",
145
  gen_kwargs={
146
- "data_file": downloaded_files["train_termination"],
147
- "split": "termination",
148
  },
149
  ),
150
  datasets.SplitGenerator(
151
- name="validation_termination",
152
  gen_kwargs={
153
- "data_file": downloaded_files["validation_termination"],
154
- "split": "termination",
155
  },
156
  ),
157
  ]
@@ -168,23 +158,23 @@ class LongTermCareAggregatedData(datasets.GeneratorBasedBuilder):
168
  feature_dict = {column: row[column] for column in feature_columns if column in dataframe.columns}
169
  yield idx, feature_dict
170
 
171
- def _get_feature_columns_by_config(self):
172
- if self.config.name == "incidence":
173
- return [
174
- "Group_Indicator", "Gender", "Issue_Age_Bucket", "Incurred_Age_Bucket",
175
- "Issue_Year_Bucket", "Policy_Year", "Marital_Status", "Premium_Class",
176
- "Underwriting_Type", "Coverage_Type_Bucket", "Tax_Qualification_Status",
177
- "Inflation_Rider", "Rate_Increase_Flag", "Restoration_of_Benefits",
178
- "NH_Orig_Daily_Ben_Bucket", "ALF_Orig_Daily_Ben_Bucket", "HHC_Orig_Daily_Ben_Bucket",
179
- "NH_Ben_Period_Bucket", "ALF_Ben_Period_Bucket", "HHC_Ben_Period_Bucket",
180
- "NH_EP_Bucket", "ALF_EP_Bucket", "HHC_EP_Bucket", "Region",
181
- "Active_Exposure", "Total_Exposure", "Claim_Count", "Count_NH", "Count_ALF", "Count_HHC", "Count_Unk",
182
- ]
183
- elif self.config.name == "termination":
184
- return [
185
- "Gender", "Incurred_Age_Bucket", "Incurred_Year_Bucket", "Claim_Type",
186
- "Region", "Diagnosis_Category", "Claim_Duration", "Exposure", "Deaths",
187
- "Recovery", "Terminations", "Benefit_Expiry", "Others_Terminations",
188
- ]
189
- else:
190
- raise ValueError(f"Config name not recognized: {self.config.name}")
 
121
  citation="Please cite this dataset as: Society of Actuaries (SOA). (2020). Long Term Care Insurance Aggregate Experience Data, 2000-2016."
122
  )
123
 
 
124
 
125
+ def _split_generators(self, dl_manager):
126
  downloaded_files = dl_manager.download(_URLS)
127
 
128
+ # 基于配置名确定文件路径
129
+ train_file = downloaded_files[f"train_{self.config.name}"]
130
+ validation_file = downloaded_files[f"validation_{self.config.name}"]
131
+
132
  return [
133
  datasets.SplitGenerator(
134
+ name=datasets.Split.TRAIN,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  gen_kwargs={
136
+ "data_file": train_file,
137
+ "split": self.config.name, # 使用配置名作为 split 参数(如果需要)
138
  },
139
  ),
140
  datasets.SplitGenerator(
141
+ name=datasets.Split.VALIDATION,
142
  gen_kwargs={
143
+ "data_file": validation_file,
144
+ "split": self.config.name, # 使用配置名作为 split 参数(如果需要)
145
  },
146
  ),
147
  ]
 
158
  feature_dict = {column: row[column] for column in feature_columns if column in dataframe.columns}
159
  yield idx, feature_dict
160
 
161
+ def _get_feature_columns_by_config(self):
162
+ if self.config.name == "incidence":
163
+ return [
164
+ "Group_Indicator", "Gender", "Issue_Age_Bucket", "Incurred_Age_Bucket",
165
+ "Issue_Year_Bucket", "Policy_Year", "Marital_Status", "Premium_Class",
166
+ "Underwriting_Type", "Coverage_Type_Bucket", "Tax_Qualification_Status",
167
+ "Inflation_Rider", "Rate_Increase_Flag", "Restoration_of_Benefits",
168
+ "NH_Orig_Daily_Ben_Bucket", "ALF_Orig_Daily_Ben_Bucket", "HHC_Orig_Daily_Ben_Bucket",
169
+ "NH_Ben_Period_Bucket", "ALF_Ben_Period_Bucket", "HHC_Ben_Period_Bucket",
170
+ "NH_EP_Bucket", "ALF_EP_Bucket", "HHC_EP_Bucket", "Region",
171
+ "Active_Exposure", "Total_Exposure", "Claim_Count", "Count_NH", "Count_ALF", "Count_HHC", "Count_Unk",
172
+ ]
173
+ elif self.config.name == "termination":
174
+ return [
175
+ "Gender", "Incurred_Age_Bucket", "Incurred_Year_Bucket", "Claim_Type",
176
+ "Region", "Diagnosis_Category", "Claim_Duration", "Exposure", "Deaths",
177
+ "Recovery", "Terminations", "Benefit_Expiry", "Others_Terminations",
178
+ ]
179
+ else:
180
+ raise ValueError(f"Config name not recognized: {self.config.name}")