Datasets:
updated to datasets 4.*
Browse files- README.md +11 -9
- Test_Dataset.csv +0 -3
- Train_Dataset.csv +0 -3
- default/train.csv +0 -0
- nbfi.py +0 -264
README.md
CHANGED
|
@@ -1,18 +1,20 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
-
- nbfi
|
| 6 |
- tabular_classification
|
| 7 |
- binary_classification
|
| 8 |
-
|
| 9 |
-
size_categories:
|
| 10 |
-
- 1K<n<10K
|
| 11 |
task_categories:
|
| 12 |
- tabular-classification
|
| 13 |
-
configs:
|
| 14 |
-
- default
|
| 15 |
-
license: cc
|
| 16 |
---
|
| 17 |
# NBFI
|
| 18 |
The [NBFI dataset](https://www.kaggle.com/datasets/meastanmay/nbfi-vehicle-loan-repayment-dataset) from the [Kaggle](https://www.kaggle.com/datasets).
|
|
|
|
| 1 |
---
|
| 2 |
+
configs:
|
| 3 |
+
- config_name: default
|
| 4 |
+
data_files:
|
| 5 |
+
- path: default/train.csv
|
| 6 |
+
split: train
|
| 7 |
+
default: true
|
| 8 |
+
language: en
|
| 9 |
+
license: cc
|
| 10 |
+
pretty_name: Nbfi
|
| 11 |
+
size_categories: 1M<n<10M
|
| 12 |
tags:
|
|
|
|
| 13 |
- tabular_classification
|
| 14 |
- binary_classification
|
| 15 |
+
- multiclass_classification
|
|
|
|
|
|
|
| 16 |
task_categories:
|
| 17 |
- tabular-classification
|
|
|
|
|
|
|
|
|
|
| 18 |
---
|
| 19 |
# NBFI
|
| 20 |
The [NBFI dataset](https://www.kaggle.com/datasets/meastanmay/nbfi-vehicle-loan-repayment-dataset) from the [Kaggle](https://www.kaggle.com/datasets).
|
Test_Dataset.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:fce61c89339cc849186d4e9964c8d154c933359ea51e5c8d401c4312040aa137
|
| 3 |
-
size 15229326
|
|
|
|
|
|
|
|
|
|
|
|
Train_Dataset.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:bfaa92b0e2bf3cb523c2c287d00502328bdc19366cdb2a49486c58ce7cae5e33
|
| 3 |
-
size 23193688
|
|
|
|
|
|
|
|
|
|
|
|
default/train.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
nbfi.py
DELETED
|
@@ -1,264 +0,0 @@
|
|
| 1 |
-
"""NBFI"""
|
| 2 |
-
|
| 3 |
-
from typing import List
|
| 4 |
-
from functools import partial
|
| 5 |
-
|
| 6 |
-
import datasets
|
| 7 |
-
|
| 8 |
-
import pandas
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
VERSION = datasets.Version("1.0.0")
|
| 12 |
-
_ORIGINAL_FEATURE_NAMES = [
|
| 13 |
-
"ID",
|
| 14 |
-
"Client_Income",
|
| 15 |
-
"Car_Owned",
|
| 16 |
-
"Bike_Owned",
|
| 17 |
-
"Active_Loan",
|
| 18 |
-
"House_Own",
|
| 19 |
-
"Child_Count",
|
| 20 |
-
"Credit_Amount",
|
| 21 |
-
"Loan_Annuity",
|
| 22 |
-
"Accompany_Client",
|
| 23 |
-
"Client_Income_Type",
|
| 24 |
-
"Client_Education",
|
| 25 |
-
"Client_Marital_Status",
|
| 26 |
-
"Client_Gender",
|
| 27 |
-
"Loan_Contract_Type",
|
| 28 |
-
"Client_Housing_Type",
|
| 29 |
-
"Population_Region_Relative",
|
| 30 |
-
"Age_Days",
|
| 31 |
-
"Employed_Days",
|
| 32 |
-
"Registration_Days",
|
| 33 |
-
"ID_Days",
|
| 34 |
-
"Own_House_Age",
|
| 35 |
-
"Mobile_Tag",
|
| 36 |
-
"Homephone_Tag",
|
| 37 |
-
"Workphone_Working",
|
| 38 |
-
"Client_Occupation",
|
| 39 |
-
"Client_Family_Members",
|
| 40 |
-
"Cleint_City_Rating",
|
| 41 |
-
"Application_Process_Day",
|
| 42 |
-
"Application_Process_Hour",
|
| 43 |
-
"Client_Permanent_Match_Tag",
|
| 44 |
-
"Client_Contact_Work_Tag",
|
| 45 |
-
"Type_Organization",
|
| 46 |
-
"Score_Source_1",
|
| 47 |
-
"Score_Source_2",
|
| 48 |
-
"Score_Source_3",
|
| 49 |
-
"Social_Circle_Default",
|
| 50 |
-
"Phone_Change",
|
| 51 |
-
"Credit_Bureau",
|
| 52 |
-
"Default"
|
| 53 |
-
]
|
| 54 |
-
_BASE_FEATURE_NAMES = [
|
| 55 |
-
"income",
|
| 56 |
-
"owns_a_car",
|
| 57 |
-
"owns_a_bike",
|
| 58 |
-
"has_an_active_loan",
|
| 59 |
-
"owns_a_house",
|
| 60 |
-
"nr_children",
|
| 61 |
-
"credit",
|
| 62 |
-
"loan_annuity",
|
| 63 |
-
"accompanied_by",
|
| 64 |
-
"income_type",
|
| 65 |
-
"education_level",
|
| 66 |
-
"marital_status",
|
| 67 |
-
"is_male",
|
| 68 |
-
"type_of_contract",
|
| 69 |
-
"type_of_housing",
|
| 70 |
-
"residence_density",
|
| 71 |
-
"age_in_days",
|
| 72 |
-
"consecutive_days_of_employment",
|
| 73 |
-
"nr_days_since_last_registration_change",
|
| 74 |
-
"nr_days_since_last_document_change",
|
| 75 |
-
"has_provided_a_mobile_number",
|
| 76 |
-
"has_provided_a_home_number",
|
| 77 |
-
"was_reachable_at_work",
|
| 78 |
-
"job",
|
| 79 |
-
"nr_family_members",
|
| 80 |
-
"city_rating",
|
| 81 |
-
"weekday_of_application",
|
| 82 |
-
"hour_of_application",
|
| 83 |
-
"same_residence_and_home",
|
| 84 |
-
"same_work_and_home",
|
| 85 |
-
"score_1",
|
| 86 |
-
"score_2",
|
| 87 |
-
"score_3",
|
| 88 |
-
"nr_defaults_in_social_circle",
|
| 89 |
-
"inquiries_in_last_year",
|
| 90 |
-
"has_defaulted"
|
| 91 |
-
]
|
| 92 |
-
features_types_per_config = {
|
| 93 |
-
"default": {
|
| 94 |
-
"income": datasets.Value("float32"),
|
| 95 |
-
"owns_a_car": datasets.Value("bool"),
|
| 96 |
-
"owns_a_bike": datasets.Value("bool"),
|
| 97 |
-
"has_an_active_loan": datasets.Value("bool"),
|
| 98 |
-
"owns_a_house": datasets.Value("bool"),
|
| 99 |
-
"nr_children": datasets.Value("int8"),
|
| 100 |
-
"credit": datasets.Value("float32"),
|
| 101 |
-
"loan_annuity": datasets.Value("float32"),
|
| 102 |
-
"accompanied_by": datasets.Value("string"),
|
| 103 |
-
"income_type": datasets.Value("string"),
|
| 104 |
-
"education_level": datasets.Value("float32"),
|
| 105 |
-
"marital_status": datasets.Value("string"),
|
| 106 |
-
"is_male": datasets.Value("bool"),
|
| 107 |
-
"type_of_contract": datasets.Value("string"),
|
| 108 |
-
"type_of_housing": datasets.Value("string"),
|
| 109 |
-
"residence_density": datasets.Value("float32"),
|
| 110 |
-
"age_in_days": datasets.Value("int32"),
|
| 111 |
-
"consecutive_days_of_employment": datasets.Value("int16"),
|
| 112 |
-
"nr_days_since_last_registration_change": datasets.Value("int32"),
|
| 113 |
-
"nr_days_since_last_document_change": datasets.Value("int32"),
|
| 114 |
-
"has_provided_a_mobile_number": datasets.Value("bool"),
|
| 115 |
-
"has_provided_a_home_number": datasets.Value("bool"),
|
| 116 |
-
"was_reachable_at_work": datasets.Value("bool"),
|
| 117 |
-
"job": datasets.Value("string"),
|
| 118 |
-
"nr_family_members": datasets.Value("int8"),
|
| 119 |
-
"city_rating": datasets.Value("int8"),
|
| 120 |
-
"weekday_of_application": datasets.Value("int8"),
|
| 121 |
-
"hour_of_application": datasets.Value("float32"),
|
| 122 |
-
"same_residence_and_home": datasets.Value("bool"),
|
| 123 |
-
"same_work_and_home": datasets.Value("bool"),
|
| 124 |
-
"score_1": datasets.Value("float32"),
|
| 125 |
-
"score_2": datasets.Value("float32"),
|
| 126 |
-
"score_3": datasets.Value("float32"),
|
| 127 |
-
"nr_defaults_in_social_circle": datasets.Value("bool"),
|
| 128 |
-
"inquiries_in_last_year": datasets.Value("float32"),
|
| 129 |
-
"has_defaulted": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
|
| 130 |
-
}
|
| 131 |
-
}
|
| 132 |
-
_ENCODING_DICS = {}
|
| 133 |
-
_EDUCATION_ENCODING = {
|
| 134 |
-
"Junior secondary": 0,
|
| 135 |
-
"Secondary": 1,
|
| 136 |
-
"Graduation dropout": 2,
|
| 137 |
-
"Graduation": 2,
|
| 138 |
-
"Post Grad": 4
|
| 139 |
-
}
|
| 140 |
-
|
| 141 |
-
DESCRIPTION = "NBFI dataset from default prediction."
|
| 142 |
-
_HOMEPAGE = "https://www.kaggle.com/datasets/meastanmay/nbfi-vehicle-loan-repayment-dataset"
|
| 143 |
-
_URLS = ("https://www.kaggle.com/datasets/meastanmay/nbfi-vehicle-loan-repayment-dataset")
|
| 144 |
-
_CITATION = """"""
|
| 145 |
-
|
| 146 |
-
# Dataset info
|
| 147 |
-
urls_per_split = {
|
| 148 |
-
"train": "https://gist.githubusercontent.com/msetzu/6c83dc3b7092d428ae2f08dc91e1020c/raw/9fc3171b293d0dc29963357450308eb4c7e3a15b/Train_Dataset.csv"
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
class NBFIConfig(datasets.BuilderConfig):
|
| 155 |
-
def __init__(self, **kwargs):
|
| 156 |
-
super(NBFIConfig, self).__init__(version=VERSION, **kwargs)
|
| 157 |
-
self.features = features_per_config[kwargs["name"]]
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
class NBFI(datasets.GeneratorBasedBuilder):
|
| 161 |
-
# dataset versions
|
| 162 |
-
DEFAULT_CONFIG = "default"
|
| 163 |
-
BUILDER_CONFIGS = [
|
| 164 |
-
NBFIConfig(name="default",
|
| 165 |
-
description="NBFI for default binary classification.")
|
| 166 |
-
]
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
def _info(self):
|
| 170 |
-
if self.config.name not in features_per_config:
|
| 171 |
-
raise ValueError(f"Unknown configuration: {self.config.name}")
|
| 172 |
-
|
| 173 |
-
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
| 174 |
-
features=features_per_config[self.config.name])
|
| 175 |
-
|
| 176 |
-
return info
|
| 177 |
-
|
| 178 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
| 179 |
-
downloads = dl_manager.download_and_extract(urls_per_split)
|
| 180 |
-
|
| 181 |
-
return [
|
| 182 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]})
|
| 183 |
-
]
|
| 184 |
-
|
| 185 |
-
def _generate_examples(self, filepath: str):
|
| 186 |
-
if self.config.name == "default":
|
| 187 |
-
data = pandas.read_csv(filepath)
|
| 188 |
-
data = self.preprocess(data, config=self.config.name)
|
| 189 |
-
|
| 190 |
-
for row_id, row in data.iterrows():
|
| 191 |
-
data_row = dict(row)
|
| 192 |
-
|
| 193 |
-
yield row_id, data_row
|
| 194 |
-
else:
|
| 195 |
-
raise ValueError(f"Unknown config: {self.config.name}")
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
def preprocess(self, data: pandas.DataFrame, config: str = DEFAULT_CONFIG) -> pandas.DataFrame:
|
| 200 |
-
data.drop("ID", axis="columns", inplace=True)
|
| 201 |
-
data.drop("Own_House_Age", axis="columns", inplace=True)
|
| 202 |
-
data.drop("Type_Organization", axis="columns", inplace=True)
|
| 203 |
-
data.drop("Phone_Change", axis="columns", inplace=True)
|
| 204 |
-
|
| 205 |
-
data = data[~data.Client_Income.isna()]
|
| 206 |
-
data = data[~data.Client_Education.isna()]
|
| 207 |
-
data = data[~data.Child_Count.isna()]
|
| 208 |
-
data = data[~data.Client_Marital_Status.isna()]
|
| 209 |
-
data = data[~data.Client_Gender.isna()]
|
| 210 |
-
data = data[~data.Loan_Contract_Type.isna()]
|
| 211 |
-
data = data[~data.Client_Housing_Type.isna()]
|
| 212 |
-
data = data[~data.Age_Days.isna()]
|
| 213 |
-
data = data[~data.Employed_Days.isna()]
|
| 214 |
-
data = data[~data.Registration_Days.isna()]
|
| 215 |
-
data = data[~data.ID_Days.isna()]
|
| 216 |
-
data = data[~data.Cleint_City_Rating.isna()]
|
| 217 |
-
data = data[~data.Application_Process_Day.isna()]
|
| 218 |
-
data = data[~data.Application_Process_Hour.isna()]
|
| 219 |
-
data = data[~data.Client_Permanent_Match_Tag.isna()]
|
| 220 |
-
data = data[~data.Client_Contact_Work_Tag.isna()]
|
| 221 |
-
data = data[~data.Score_Source_1.isna()]
|
| 222 |
-
data = data[~data.Score_Source_2.isna()]
|
| 223 |
-
data = data[~data.Score_Source_3.isna()]
|
| 224 |
-
data = data[~data.Credit_Bureau.isna()]
|
| 225 |
-
data = data[~data.Credit_Amount.isna()]
|
| 226 |
-
data = data[~data.Loan_Annuity.isna()]
|
| 227 |
-
data = data[~data.Accompany_Client.isna()]
|
| 228 |
-
data = data[~data.Client_Occupation.isna()]
|
| 229 |
-
data = data[~data.Client_Family_Members.isna()]
|
| 230 |
-
data = data[~data.Social_Circle_Default.isna()]
|
| 231 |
-
data = data[~data.Population_Region_Relative.isin(("@", "#"))]
|
| 232 |
-
data = data[~data.Population_Region_Relative.isna()]
|
| 233 |
-
data = data[data.Loan_Annuity != "#VALUE!"]
|
| 234 |
-
data = data[data.Age_Days != "x"]
|
| 235 |
-
data = data[data.Employed_Days != "x"]
|
| 236 |
-
data = data[data.Registration_Days != "x"]
|
| 237 |
-
data = data[data.ID_Days != "x"]
|
| 238 |
-
|
| 239 |
-
data.columns = _BASE_FEATURE_NAMES
|
| 240 |
-
|
| 241 |
-
data["education_level"] = data["education_level"].apply(lambda x: _EDUCATION_ENCODING[x])
|
| 242 |
-
data["is_male"] = data["is_male"].apply(lambda x: x == "M")
|
| 243 |
-
data["owns_a_car"] = data["owns_a_car"].apply(bool)
|
| 244 |
-
data["owns_a_bike"] = data["owns_a_bike"].apply(bool)
|
| 245 |
-
data["has_an_active_loan"] = data["has_an_active_loan"].apply(bool)
|
| 246 |
-
data["owns_a_house"] = data["owns_a_house"].apply(bool)
|
| 247 |
-
data["is_male"] = data["is_male"].apply(bool)
|
| 248 |
-
data["has_provided_a_mobile_number"] = data["has_provided_a_mobile_number"].apply(bool)
|
| 249 |
-
data["has_provided_a_home_number"] = data["has_provided_a_home_number"].apply(bool)
|
| 250 |
-
data["was_reachable_at_work"] = data["was_reachable_at_work"].apply(bool)
|
| 251 |
-
data["same_residence_and_home"] = data["same_residence_and_home"].apply(bool)
|
| 252 |
-
data["same_work_and_home"] = data["same_work_and_home"].apply(bool)
|
| 253 |
-
data["nr_defaults_in_social_circle"] = data["same_work_and_home"].apply(bool)
|
| 254 |
-
data["residence_density"] = data["residence_density"].apply(float)
|
| 255 |
-
|
| 256 |
-
data = data.astype({
|
| 257 |
-
"is_male": "bool",
|
| 258 |
-
"nr_children": "int8"
|
| 259 |
-
})
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
return data[list(features_types_per_config[config].keys())]
|
| 264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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