mstz commited on
Commit
8d066cd
·
1 Parent(s): 492e05f

Upload german.py

Browse files
Files changed (1) hide show
  1. german.py +37 -0
german.py CHANGED
@@ -197,6 +197,7 @@ class Breast(datasets.GeneratorBasedBuilder):
197
  data.loc[:, "job_status"] = data.job_status.apply(self.encode_job_status)
198
  data.loc[:, "marital_status"] = data.personal_status_and_sex.apply(self.encode_marital_status)
199
  data.loc[:, "sex"] = data.personal_status_and_sex.apply(self.encode_sex)
 
200
  data.loc[:, "loan_granted"] = data.loan_granted.apply(lambda x: x - 1)
201
 
202
  data.drop("personal_status_and_sex", axis="columns", inplace=True)
@@ -464,3 +465,39 @@ class Breast(datasets.GeneratorBasedBuilder):
464
  0: "A201",
465
  1: "A202",
466
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  data.loc[:, "job_status"] = data.job_status.apply(self.encode_job_status)
198
  data.loc[:, "marital_status"] = data.personal_status_and_sex.apply(self.encode_marital_status)
199
  data.loc[:, "sex"] = data.personal_status_and_sex.apply(self.encode_sex)
200
+ data.loc[:, "loan_purpose"] = data.loan_purpose.apply(self.encode_loan_purpose)
201
  data.loc[:, "loan_granted"] = data.loan_granted.apply(lambda x: x - 1)
202
 
203
  data.drop("personal_status_and_sex", axis="columns", inplace=True)
 
465
  0: "A201",
466
  1: "A202",
467
  }
468
+
469
+ def encode_loan_purpose(self, status):
470
+ return self.loan_purpose_encode_dic()[status]
471
+
472
+ def loan_purpose_encode_dic(self):
473
+ return {
474
+ "A40": "new car",
475
+ "A41": "used car",
476
+ "A42": "furniture/equipment",
477
+ "A43": "radio/television",
478
+ "A44": "domestic appliances",
479
+ "A45": "repairs",
480
+ "A46": "education",
481
+ "A47": "vacation ",
482
+ "A48": "retraining",
483
+ "A49": "business",
484
+ "A410": "others"
485
+ }
486
+
487
+ def decode_loan_purpose(self, code):
488
+ return self.loan_purpose_decode_dic()[code]
489
+
490
+ def loan_purpose_decode_dic(self):
491
+ return {
492
+ "new car": "A40",
493
+ "used car": "A41",
494
+ "furniture/equipment": "A42",
495
+ "radio/television": "A43",
496
+ "domestic appliances": "A44",
497
+ "repairs": "A45",
498
+ "education": "A46",
499
+ "vacation ": "A47",
500
+ "retraining": "A48",
501
+ "business": "A49",
502
+ "others": "A410"
503
+ }