| --- |
| dataset_info: |
| features: |
| - name: status of existing checking account |
| dtype: |
| class_label: |
| names: |
| '0': < 0 DM |
| '1': 0 <= ... < 200 DM |
| '2': '>= 200 DM / salary assignments for at least 1 year' |
| '3': no checking account |
| - name: duration in month |
| dtype: int64 |
| - name: credit history |
| dtype: |
| class_label: |
| names: |
| '0': no credits taken / all credits paid back duly |
| '1': all credits at this bank paid back duly |
| '2': existing credits paid back duly till now |
| '3': delay in paying off in the past |
| '4': critical account / other credits existing (not at this bank) |
| - name: purpose |
| dtype: |
| class_label: |
| names: |
| '0': car (new) |
| '1': car (used) |
| '2': furniture/equipment |
| '3': radio/television |
| '4': domestic appliances |
| '5': repairs |
| '6': education |
| '7': vacation |
| '8': retraining |
| '9': business |
| '10': others |
| - name: credit amount |
| dtype: int64 |
| - name: savings account/bonds |
| dtype: |
| class_label: |
| names: |
| '0': < 100 DM |
| '1': 100 <= ... < 500 DM |
| '2': 500 <= ... < 1000 DM |
| '3': '>= 1000 DM' |
| '4': unknown / no savings account |
| - name: present employment since |
| dtype: |
| class_label: |
| names: |
| '0': unemployed |
| '1': < 1 year |
| '2': 1 <= ... < 4 years |
| '3': 4 <= ... < 7 years |
| '4': '>= 7 years' |
| - name: installment rate in percentage of disposable income |
| dtype: int64 |
| - name: personal status and sex |
| dtype: |
| class_label: |
| names: |
| '0': 'male: divorced/separated' |
| '1': 'female: divorced/separated/married' |
| '2': 'male: single' |
| '3': 'male: married/widowed' |
| '4': 'female: single' |
| - name: other debtors / guarantors |
| dtype: |
| class_label: |
| names: |
| '0': none |
| '1': co-applicant |
| '2': guarantor |
| - name: present residence since |
| dtype: int64 |
| - name: property |
| dtype: |
| class_label: |
| names: |
| '0': real estate |
| '1': building society savings agreement / life insurance |
| '2': car or other, not in attribute 6 |
| '3': unknown / no property |
| - name: age in years |
| dtype: int64 |
| - name: other installment plans |
| dtype: |
| class_label: |
| names: |
| '0': bank |
| '1': stores |
| '2': none |
| - name: housing |
| dtype: |
| class_label: |
| names: |
| '0': rent |
| '1': own |
| '2': for free |
| - name: number of existing credits at this bank |
| dtype: int64 |
| - name: job |
| dtype: |
| class_label: |
| names: |
| '0': unemployed / unskilled - non-resident |
| '1': unskilled - resident |
| '2': skilled employee / official |
| '3': management / self-employed / highly qualified employee / officer |
| - name: number of people being liable to provide maintenance for |
| dtype: int64 |
| - name: telephone |
| dtype: |
| class_label: |
| names: |
| '0': none |
| '1': yes, registered under the customer’s name |
| - name: foreign worker |
| dtype: |
| class_label: |
| names: |
| '0': 'yes' |
| '1': 'no' |
| - name: class |
| dtype: |
| class_label: |
| names: |
| '0': good |
| '1': bad |
| splits: |
| - name: train |
| num_bytes: 168000 |
| num_examples: 1000 |
| download_size: 25200 |
| dataset_size: 168000 |
| configs: |
| - config_name: default |
| data_files: |
| - split: train |
| path: data/train-* |
| --- |
| |
| # Dataset Card for Dataset Name |
|
|
| This dataset is a precise version of [Statlog (German Credit Data)](https://archive.ics.uci.edu/dataset/144/statlog+german+credit+data), donated on 11/16/1994. |
|
|
| We used the following Python script to produce this Hugging Face dataset. |
|
|
| ```python |
| columns = [ |
| "status of existing checking account", # 1 (categorical) |
| "duration in month", # 2 (numerical) |
| "credit history", # 3 (categorical) |
| "purpose", # 4 (categorical) |
| "credit amount", # 5 (numerical) |
| "savings account/bonds", # 6 (categorical) |
| "present employment since", # 7 (categorical) |
| "installment rate in percentage of disposable income", # 8 (numerical) |
| "personal status and sex", # 9 (categorical) |
| "other debtors / guarantors", # 10 (categorical) |
| "present residence since", # 11 (numerical) |
| "property", # 12 (categorical) |
| "age in years", # 13 (numerical) |
| "other installment plans", # 14 (categorical) |
| "housing", # 15 (categorical) |
| "number of existing credits at this bank", # 16 (numerical) |
| "job", # 17 (categorical) |
| "number of people being liable to provide maintenance for", # 18 (numerical) |
| "telephone", # 19 (categorical) |
| "foreign worker", # 20 (categorical) |
| "class" # 21 (target label, categorical) |
| ] |
| |
| |
| continuous_columns = [ |
| "duration in month", "credit amount", |
| "installment rate in percentage of disposable income", |
| "present residence since", "age in years", |
| "number of existing credits at this bank", |
| "number of people being liable to provide maintenance for" |
| ] |
| |
| categorical_columns = [ |
| "status of existing checking account", "credit history", "purpose", |
| "savings account/bonds", "present employment since", |
| "personal status and sex", "other debtors / guarantors", "property", |
| "other installment plans", "housing", "job", "telephone", |
| "foreign worker", "class" |
| ] |
| |
| |
| import pandas as pd |
| |
| # File path |
| file_path_categorical = "https://archive.ics.uci.edu/ml/machine-learning-databases/statlog/german/german.data" |
| |
| # Load dataset |
| df_categorical = pd.read_csv(file_path_categorical, sep=" ", names=columns, skipinitialspace=True) |
| |
| # Convert categorical features to integer indices |
| category_mappings = {} |
| |
| for col in categorical_columns: |
| df_categorical[col] = df_categorical[col].astype("category") |
| category_mappings[col] = list(df_categorical[col].cat.categories) |
| df_categorical[col] = df_categorical[col].cat.codes # Convert to int indices |
| |
| df_categorical = df_categorical[columns] |
| |
| |
| final_mappings = { |
| "status of existing checking account": { |
| "A11": "< 0 DM", |
| "A12": "0 <= ... < 200 DM", |
| "A13": ">= 200 DM / salary assignments for at least 1 year", |
| "A14": "no checking account" |
| }, |
| "credit history": { |
| "A30": "no credits taken / all credits paid back duly", |
| "A31": "all credits at this bank paid back duly", |
| "A32": "existing credits paid back duly till now", |
| "A33": "delay in paying off in the past", |
| "A34": "critical account / other credits existing (not at this bank)" |
| }, |
| "purpose": { |
| "A40": "car (new)", |
| "A41": "car (used)", |
| "A42": "furniture/equipment", |
| "A43": "radio/television", |
| "A44": "domestic appliances", |
| "A45": "repairs", |
| "A46": "education", |
| "A47": "vacation", |
| "A48": "retraining", |
| "A49": "business", |
| "A410": "others" |
| }, |
| "savings account/bonds": { |
| "A61": "< 100 DM", |
| "A62": "100 <= ... < 500 DM", |
| "A63": "500 <= ... < 1000 DM", |
| "A64": ">= 1000 DM", |
| "A65": "unknown / no savings account" |
| }, |
| "present employment since": { |
| "A71": "unemployed", |
| "A72": "< 1 year", |
| "A73": "1 <= ... < 4 years", |
| "A74": "4 <= ... < 7 years", |
| "A75": ">= 7 years" |
| }, |
| "personal status and sex": { |
| "A91": "male: divorced/separated", |
| "A92": "female: divorced/separated/married", |
| "A93": "male: single", |
| "A94": "male: married/widowed", |
| "A95": "female: single" |
| }, |
| "other debtors / guarantors": { |
| "A101": "none", |
| "A102": "co-applicant", |
| "A103": "guarantor" |
| }, |
| "property": { |
| "A121": "real estate", |
| "A122": "building society savings agreement / life insurance", |
| "A123": "car or other, not in attribute 6", |
| "A124": "unknown / no property" |
| }, |
| "other installment plans": { |
| "A141": "bank", |
| "A142": "stores", |
| "A143": "none" |
| }, |
| "housing": { |
| "A151": "rent", |
| "A152": "own", |
| "A153": "for free" |
| }, |
| "job": { |
| "A171": "unemployed / unskilled - non-resident", |
| "A172": "unskilled - resident", |
| "A173": "skilled employee / official", |
| "A174": "management / self-employed / highly qualified employee / officer" |
| }, |
| "telephone": { |
| "A191": "none", |
| "A192": "yes, registered under the customer’s name" |
| }, |
| "foreign worker": { |
| "A201": "yes", |
| "A202": "no" |
| }, |
| "class": { |
| "1": "good", |
| "2": "bad" |
| } |
| } |
| |
| |
| from datasets import Dataset, DatasetDict, Features, Value, ClassLabel |
| |
| hf_features_categorical = Features({ |
| col: Value("int64") if col in continuous_columns else |
| ClassLabel(names=list(final_mappings[col].values())) if col in final_mappings else |
| ClassLabel(names=["good", "bad"]) # "class" column |
| for col in columns |
| }) |
| |
| from datasets import DatasetDict |
| |
| # Convert pandas DataFrame to Hugging Face Dataset |
| df_categorical = df_categorical[columns] |
| hf_categorical = Dataset.from_pandas(df_categorical, features=hf_features_categorical) |
| |
| # Store in a dataset dictionary |
| hf_dataset_categorical = DatasetDict({"train": hf_categorical}) |
| |
| # Print dataset structure |
| print(hf_dataset_categorical) |
| ``` |
|
|
| The printed output could look like |
|
|
| ``` |
| DatasetDict({ |
| train: Dataset({ |
| features: ['status of existing checking account', 'duration in month', 'credit history', 'purpose', 'credit amount', 'savings account/bonds', 'present employment since', 'installment rate in percentage of disposable income', 'personal status and sex', 'other debtors / guarantors', 'present residence since', 'property', 'age in years', 'other installment plans', 'housing', 'number of existing credits at this bank', 'job', 'number of people being liable to provide maintenance for', 'telephone', 'foreign worker', 'class'], |
| num_rows: 1000 |
| }) |
| }) |
| ``` |
|
|
| Note that there is another [file](https://archive.ics.uci.edu/ml/machine-learning-databases/statlog/german/german.data-numeric) for numerical data, but seems that the content is not more than what we have so far, so we don't include it. |