Datasets:
Upload 4 files
Browse files- .gitattributes +2 -0
- README.md +61 -0
- Test_Dataset.csv +3 -0
- Train_Dataset.csv +3 -0
- nbfi.py +235 -0
.gitattributes
CHANGED
|
@@ -52,3 +52,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 52 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 53 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 52 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 53 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
Test_Dataset.csv filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
Train_Dataset.csv filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
tags:
|
| 5 |
+
- nbfi
|
| 6 |
+
- tabular_classification
|
| 7 |
+
- binary_classification
|
| 8 |
+
pretty_name: Adult
|
| 9 |
+
size_categories:
|
| 10 |
+
- 10K<n<100K
|
| 11 |
+
task_categories: # Full list at https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts
|
| 12 |
+
- tabular-classification
|
| 13 |
+
configs:
|
| 14 |
+
- default
|
| 15 |
+
---
|
| 16 |
+
# NBFI
|
| 17 |
+
The [NBFI dataset](https://www.kaggle.com/datasets/meastanmay/nbfi-vehicle-loan-repayment-dataset) from the [Kaggle](https://www.kaggle.com/datasets).
|
| 18 |
+
Client default prediction
|
| 19 |
+
|
| 20 |
+
# Configurations and tasks
|
| 21 |
+
- `default`, for binary classification of the individual's future default status.
|
| 22 |
+
|
| 23 |
+
# Features
|
| 24 |
+
|**Feature** |**Type** |
|
| 25 |
+
|-----------------------------------------------|---------------|
|
| 26 |
+
|`income` | `float32` |
|
| 27 |
+
|`owns_a_car` | `bool` |
|
| 28 |
+
|`owns_a_bike` | `bool` |
|
| 29 |
+
|`has_an_active_loan` | `bool` |
|
| 30 |
+
|`owns_a_house` | `bool` |
|
| 31 |
+
|`nr_children` | `int8` |
|
| 32 |
+
|`credit` | `float32` |
|
| 33 |
+
|`loan_annuity` | `float32` |
|
| 34 |
+
|`accompanied_by` | `string` |
|
| 35 |
+
|`income_type` | `string` |
|
| 36 |
+
|`education_level` | `float32` |
|
| 37 |
+
|`marital_status` | `float32` |
|
| 38 |
+
|`is_male` | `bool` |
|
| 39 |
+
|`type_of_contract` | `string` |
|
| 40 |
+
|`type_of_housing` | `string` |
|
| 41 |
+
|`residence_density` | `float32` |
|
| 42 |
+
|`age_in_days` | `int32` |
|
| 43 |
+
|`consecutive_days_of_employment` | `int16` |
|
| 44 |
+
|`nr_days_since_last_registration_change` | `int32` |
|
| 45 |
+
|`nr_days_since_last_document_change` | `int32` |
|
| 46 |
+
|`owned_a_house_for_nr_days` | `int32` |
|
| 47 |
+
|`has_provided_a_mobile_number` | `bool` |
|
| 48 |
+
|`has_provided_a_home_number` | `bool` |
|
| 49 |
+
|`was_reachable_at_work` | `bool` |
|
| 50 |
+
|`job` | `string` |
|
| 51 |
+
|`nr_family_members` | `int8` |
|
| 52 |
+
|`city_rating` | `int8` |
|
| 53 |
+
|`weekday_of_application` | `int8` |
|
| 54 |
+
|`hour_of_application` | `float32` |
|
| 55 |
+
|`same_residence_and_home` | `bool` |
|
| 56 |
+
|`same_work_and_home` | `bool` |
|
| 57 |
+
|`score_1` | `float32` |
|
| 58 |
+
|`score_2` | `float32` |
|
| 59 |
+
|`score_3` | `float32` |
|
| 60 |
+
|`nr_defaults_in_social_circle` | `int8` |
|
| 61 |
+
|`inquiries_in_last_year` | `float32` |
|
Test_Dataset.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fce61c89339cc849186d4e9964c8d154c933359ea51e5c8d401c4312040aa137
|
| 3 |
+
size 15229326
|
Train_Dataset.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bfaa92b0e2bf3cb523c2c287d00502328bdc19366cdb2a49486c58ce7cae5e33
|
| 3 |
+
size 23193688
|
nbfi.py
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
| 1 |
+
"""NBFI: A Census Dataset"""
|
| 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 |
+
"owned_a_house_for_nr_days",
|
| 76 |
+
"has_provided_a_mobile_number",
|
| 77 |
+
"has_provided_a_home_number",
|
| 78 |
+
"was_reachable_at_work",
|
| 79 |
+
"job",
|
| 80 |
+
"nr_family_members",
|
| 81 |
+
"city_rating",
|
| 82 |
+
"weekday_of_application",
|
| 83 |
+
"hour_of_application",
|
| 84 |
+
"same_residence_and_home",
|
| 85 |
+
"same_work_and_home",
|
| 86 |
+
"score_1",
|
| 87 |
+
"score_2",
|
| 88 |
+
"score_3",
|
| 89 |
+
"nr_defaults_in_social_circle",
|
| 90 |
+
"inquiries_in_last_year",
|
| 91 |
+
"has_defaulted"
|
| 92 |
+
]
|
| 93 |
+
features_types_per_config = {
|
| 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("float32"),
|
| 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 |
+
"owned_a_house_for_nr_days": datasets.Value("int32"),
|
| 115 |
+
"has_provided_a_mobile_number": datasets.Value("bool"),
|
| 116 |
+
"has_provided_a_home_number": datasets.Value("bool"),
|
| 117 |
+
"was_reachable_at_work": datasets.Value("bool"),
|
| 118 |
+
"job": datasets.Value("string"),
|
| 119 |
+
"nr_family_members": datasets.Value("int8"),
|
| 120 |
+
"city_rating": datasets.Value("int8"),
|
| 121 |
+
"weekday_of_application": datasets.Value("int8"),
|
| 122 |
+
"hour_of_application": datasets.Value("float32"),
|
| 123 |
+
"same_residence_and_home": datasets.Value("bool"),
|
| 124 |
+
"same_work_and_home": datasets.Value("bool"),
|
| 125 |
+
"score_1": datasets.Value("float32"),
|
| 126 |
+
"score_2": datasets.Value("float32"),
|
| 127 |
+
"score_3": datasets.Value("float32"),
|
| 128 |
+
"nr_defaults_in_social_circle": datasets.Value("int8"),
|
| 129 |
+
"inquiries_in_last_year": datasets.Value("float32"),
|
| 130 |
+
"has_defaulted": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
|
| 131 |
+
}
|
| 132 |
+
_ENCODING_DICS = {}
|
| 133 |
+
_EDUCATION_ENCODING = {
|
| 134 |
+
"Junior secondary": 0,
|
| 135 |
+
"Secondary": 1,
|
| 136 |
+
"Graduation dropout": 2,
|
| 137 |
+
"Graduation": 2,
|
| 138 |
+
"Post": 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://huggingface.co/datasets/mstz/nbfi/raw/main/Train_Dataset.csv",
|
| 149 |
+
"test": "https://huggingface.co/datasets/mstz/nbfi/raw/main/Test_Dataset.csv"
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
class NBFIConfig(datasets.BuilderConfig):
|
| 156 |
+
def __init__(self, **kwargs):
|
| 157 |
+
super(NBFIConfig, self).__init__(version=VERSION, **kwargs)
|
| 158 |
+
self.features = features_per_config[kwargs["name"]]
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
class NBFI(datasets.GeneratorBasedBuilder):
|
| 162 |
+
# dataset versions
|
| 163 |
+
DEFAULT_CONFIG = "default"
|
| 164 |
+
BUILDER_CONFIGS = [
|
| 165 |
+
NBFIConfig(name="default",
|
| 166 |
+
description="NBFI for default binary classification.")
|
| 167 |
+
]
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def _info(self):
|
| 171 |
+
if self.config.name not in features_per_config:
|
| 172 |
+
raise ValueError(f"Unknown configuration: {self.config.name}")
|
| 173 |
+
|
| 174 |
+
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
| 175 |
+
features=features_per_config[self.config.name])
|
| 176 |
+
|
| 177 |
+
return info
|
| 178 |
+
|
| 179 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
| 180 |
+
downloads = dl_manager.download_and_extract(urls_per_split)
|
| 181 |
+
|
| 182 |
+
return [
|
| 183 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
|
| 184 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloads["test"]}),
|
| 185 |
+
]
|
| 186 |
+
|
| 187 |
+
def _generate_examples(self, filepath: str):
|
| 188 |
+
if self.config.name == "default":
|
| 189 |
+
data = pandas.read_csv(filepath)
|
| 190 |
+
data = self.preprocess(data, config=self.config.name)
|
| 191 |
+
|
| 192 |
+
for row_id, row in data.iterrows():
|
| 193 |
+
data_row = dict(row)
|
| 194 |
+
|
| 195 |
+
yield row_id, data_row
|
| 196 |
+
else:
|
| 197 |
+
raise ValueError(f"Unknown config: {self.config.name}")
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
def preprocess(self, data: pandas.DataFrame, config: str = DEFAULT_CONFIG) -> pandas.DataFrame:
|
| 202 |
+
data.drop("ID", axis="columns", inplace=True)
|
| 203 |
+
data.drop("Own_House_Age", axis="columns", inplace=True)
|
| 204 |
+
data.drop("Type_Organization", axis="columns", inplace=True)
|
| 205 |
+
data.drop("Phone_Change", axis="columns", inplace=True)
|
| 206 |
+
|
| 207 |
+
data = data[~data.Client_Education.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.columns = _BASE_FEATURE_NAMES
|
| 222 |
+
|
| 223 |
+
data.iloc[:, "owns_a_car"] = data["owns_a_car"].apply(bool)
|
| 224 |
+
data.iloc[:, "owns_a_bike"] = data["owns_a_bike"].apply(bool)
|
| 225 |
+
data.iloc[:, "has_an_active_loan"] = data["has_an_active_loan"].apply(bool)
|
| 226 |
+
data.iloc[:, "owns_a_house"] = data["owns_a_house"].apply(bool)
|
| 227 |
+
data.iloc[:, "is_male"] = data["is_male"].apply(bool)
|
| 228 |
+
data.iloc[:, "has_provided_a_mobile_number"] = data["has_provided_a_mobile_number"].apply(bool)
|
| 229 |
+
data.iloc[:, "has_provided_a_home_number"] = data["has_provided_a_home_number"].apply(bool)
|
| 230 |
+
data.iloc[:, "was_reachable_at_work"] = data["was_reachable_at_work"].apply(bool)
|
| 231 |
+
data.iloc[:, "same_residence_and_home"] = data["same_residence_and_home"].apply(bool)
|
| 232 |
+
data.iloc[:, "same_work_and_home"] = data["same_work_and_home"].apply(bool)
|
| 233 |
+
|
| 234 |
+
return data[list(features_types_per_config[config].keys())]
|
| 235 |
+
|