image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

train_df = pd.read_csv('/kaggle/input/insurance-churn-prediction-weekend-hackathon/Insurance_Churn_ParticipantsData/Train.csv')
test_df = pd.read_csv('/kaggle/input/insurance-churn-prediction-weekend-hackathon/Insurance_Churn_ParticipantsData/Test.csv')

train_df.rename(columns={'labels': 'churn'}, inplace=True)

train_df.describe().T

def summary(df):
    Types = df.dtypes
    Counts = df.apply(lambda x: x.count())
    Uniques = df.apply(lambda x: x.unique().shape[0])
    cols = ['Types', 'Counts', 'Uniques']
    str = pd.concat([Types, Counts, Uniques], axis=1, sort=True)
    str.columns = cols
summary(df=train_df)

sizes = [29941,3967]
labels='NO','YES'
explode = (0, 0.1)  
fig1, ax1 = plt.subplots()
ax1.pie(sizes, explode=explode,autopct='%1.1f%%',shadow=True, startangle=75 )
ax1.axis('equal') 
ax1.set_title("Client Churn Distribution")

ax1.legend(labels)

plt.show()
        
 #ratio of those who churn and those who don't

def show_correlations(df, show_chart=True):
    fig = plt.figure(figsize=(20, 10))
    corr = df.corr()
    if show_chart == True:
        sns.heatmap(corr, xticklabels=corr.columns.values, yticklabels=corr.columns.values, annot=True)
    return corr
correlation_df = show_correlations(train_df, show_chart=True)