Created by SmirkyGraphs. Code: GitHub. Source: Kaggle.
# For Data
import pandas as pd
import numpy as np
# For Visualizations
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('darkgrid')
%matplotlib inline
def missingdata(frame):
frames = []
count = frame.isnull().sum()
frames.append(count)
percent = frame.isnull().sum()/frame.shape[0]
frames.append(percent)
output = pd.concat([count, percent], axis=1, keys=['Count', 'Percent'])
output = output[output['Percent'] > 0.01].sort_values('Percent', ascending=False)
if output.empty == True:
print("No missing data > 1%")
else:
return output
def graph_objects(frame, hue=None):
if hue is not None:
hue = hue
df = frame.dtypes
df.index.name = 'columns'
df = pd.DataFrame(df, columns=['dtype'])
df = df.reset_index()
df = df[df['dtype'] == 'object']
list_objects = df['columns'].tolist()
for obj in list_objects:
plt.figure(figsize=(11,5))
plot = sns.countplot(obj, data=frame, hue=hue)
plt.xticks(rotation=90)
This is the main table, broken into two files for Train (with TARGET) and Test (without TARGET).
Static data for all applications. One row represents one loan in our data sample.
application_train = pd.read_csv('./input/application_train.csv')
application_train.info(verbose=True, null_counts=True)
application_train.head()
missingdata(application_train)
sns.countplot('TARGET', data=application_train)
graph_objects(application_train, hue='TARGET')
sns.countplot('CNT_CHILDREN', data=application_train, hue='TARGET')
sns.countplot('FLAG_EMP_PHONE', data=application_train, hue='TARGET')
sns.countplot('FLAG_PHONE', data=application_train, hue='TARGET')
sns.countplot('FLAG_EMAIL', data=application_train, hue='TARGET')
sns.countplot('REGION_RATING_CLIENT', data=application_train, hue='TARGET')
sns.countplot('HOUR_APPR_PROCESS_START', data=application_train, hue='TARGET')
sns.distplot(application_train["DAYS_ID_PUBLISH"])
days_employed = application_train[application_train['DAYS_EMPLOYED'] < 365243]
sns.distplot(days_employed["DAYS_EMPLOYED"])
sns.distplot(application_train["DAYS_REGISTRATION"])
sns.distplot(application_train.OWN_CAR_AGE.dropna())
sns.distplot(application_train.CNT_FAM_MEMBERS.dropna())
sns.distplot(application_train.AMT_GOODS_PRICE.dropna())
sns.distplot(application_train.AMT_ANNUITY.dropna())
Monthly balances of previous credits in Credit Bureau.
This table has one row for each month of history of every previous credit reported to Credit Bureau i.e the table has
(#loans in sample # of relative previous credits # of months where we have some history observable for the previous credits) rows.
credit = sns.FacetGrid(application_train, hue="TARGET", height=6, aspect=2)
credit = credit.map(sns.distplot, "AMT_CREDIT")
Monthly balances of previous credits in Credit Bureau.
This table has one row for each month of history of every previous credit reported to Credit Bureau – i.e the table has
(#loans in sample # of relative previous credits # of months where we have some history observable for the previous credits) rows.
bureau_balance = pd.read_csv('./input/bureau_balance.csv')
bureau_balance.info(null_counts=True)
bureau_balance.head()
missingdata(bureau_balance)
graph_objects(bureau_balance)
All client's previous credits provided by other financial institutions that were reported to Credit Bureau (for clients who have a loan in our sample).
For every loan in our sample, there are as many rows as number of credits the client had in Credit Bureau before the application date.
bureau = pd.read_csv('./input/bureau.csv')
bureau.info(verbose=True, null_counts=True)
bureau.head()
missingdata(bureau)
graph_objects(bureau)
sns.distplot(bureau.DAYS_CREDIT.dropna())
sns.distplot(bureau.DAYS_CREDIT_UPDATE.dropna())
Monthly balance snapshots of previous credit cards that the applicant has with Home Credit.
This table has one row for each month of history of every previous credit in Home Credit (consumer credit and cash loans) related to loans in our sample
(#loans in sample # of relative previous credit cards # of months where we have some history observable for the previous credit card) rows.
credit_card_balance = pd.read_csv('./input/credit_card_balance.csv')
credit_card_balance.info(verbose=True, null_counts=True)
credit_card_balance.head()
missingdata(credit_card_balance)
graph_objects(credit_card_balance)
sns.distplot(credit_card_balance.MONTHS_BALANCE.dropna())
Repayment history for the previously disbursed credits in Home Credit related to the loans in our sample.
There is a) one row for every payment that was made plus b) one row each for missed payment.
One row is equivalent to one payment of one installment OR one installment corresponding to one payment of one previous Home Credit credit related to loans in our sample.
installments_payments = pd.read_csv('./input/installments_payments.csv')
installments_payments.info(verbose=True, null_counts=True)
installments_payments.head()
missingdata(installments_payments)
sns.distplot(installments_payments.DAYS_INSTALMENT.dropna())
sns.distplot(installments_payments.DAYS_ENTRY_PAYMENT.dropna())
Monthly balance snapshots of previous POS (point of sales) and cash loans that the applicant had with Home Credit.
This table has one row for each month of history of every previous credit in Home Credit (consumer credit and cash loans) related to loans in our sample
(#loans in sample # of relative previous credits # of months in which we have some history observable for the previous credits) rows.
POS_CASH_balance = pd.read_csv('./input/POS_CASH_balance.csv')
POS_CASH_balance.info(verbose=True, null_counts=True)
POS_CASH_balance.head()
missingdata(POS_CASH_balance)
graph_objects(POS_CASH_balance)
sns.distplot(POS_CASH_balance.MONTHS_BALANCE)
sns.distplot(POS_CASH_balance.CNT_INSTALMENT.dropna())
sns.distplot(POS_CASH_balance.CNT_INSTALMENT_FUTURE.dropna())
All previous applications for Home Credit loans of clients who have loans in our sample.
There is one row for each previous application related to loans in our data sample.
previous_application = pd.read_csv('./input/previous_application.csv')
previous_application.info(verbose=True, null_counts=True)
previous_application.head()
missingdata(previous_application)
graph_objects(previous_application)
sns.distplot(previous_application.AMT_ANNUITY.dropna())
sns.distplot(previous_application.AMT_APPLICATION.dropna())