text_plain_output_5.png text_plain_output_9.png text_plain_output_4.png image_output_5.png text_plain_output_10.png text_plain_output_6.png image_output_7.png text_plain_output_3.png image_output_4.png text_plain_output_7.png image_output_8.png text_plain_output_8.png image_output_6.png text_plain_output_2.png text_plain_output_1.png image_output_3.png image_output_2.png image_output_1.png image_output_10.png image_output_9.png
from sklearn.utils import shuffle

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

df_train = pd.read_csv('/kaggle/input/30-days-of-ml/train.csv')
df_test = pd.read_csv('/kaggle/input/30-days-of-ml/test.csv')

df_train.nunique()

df_train = df_train.drop(['id'], axis=1)

df_train = shuffle(df_train)

target = ['target']
var_categorical = ['cat0', 'cat1', 'cat2', 'cat3', 'cat4', 'cat5', 'cat6', 'cat7', 'cat8', 'cat9']
var_numerical = list(set(df_train.columns) - set(var_categorical) - set(target))

def label_values(ax, spacing=5):
    total = 0
    for rect in ax.patches:
        total += rect.get_height()
    for rect in ax.patches:
        y_value = rect.get_height()
        x_value = rect.get_x() + rect.get_width() / 2
        space = spacing
        va = 'bottom'
        if y_value < 0:
            space *= -1
            va = 'top'
        label = '{:.2f}, {:.2f}'.format(y_value, y_value / total * 100)
        ax.annotate(label, (x_value, y_value), xytext=(0, space), textcoords='offset points', ha='center', va=va)

for column in var_categorical:
    plt.figure(figsize=(15, 6))
    print(column.title())
    ax = sns.countplot(x = df_train[column])
    label_values(ax)
    plt.show()

for column in var_categorical:
    plt.figure(figsize=(15, 6))
    print(column.title())
    ax = sns.boxplot(x = df_train[column], y = df_train['target'])
    label_values(ax)
    plt.show()

i = 1
for column in var_numerical:
    i += 1
    i += 1
    i += 1

plt.figure(figsize=(15, 15))
sns.heatmap(df_train.corr(), annot=True)
plt.show()