Dataset Viewer
The dataset viewer is not available for this dataset.
Unexpected token '<', "<html>
<h"... is not valid JSON
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
Dataset Card for Dataset Name
This dataset is a precise version of Statlog (German Credit Data), donated on 11/16/1994.
We used the following Python script to produce this Hugging Face dataset.
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 for numerical data, but seems that the content is not more than what we have so far, so we don't include it.
- Downloads last month
- 11