image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

test = pd.read_csv('../input/mobile-price-classification/test.csv')
train = pd.read_csv('../input/mobile-price-classification/train.csv')

numerical = ['battery_power', 'clock_speed', 'fc', 'int_memory', 'm_dep', 'mobile_wt', 'n_cores', 'pc', 'px_height', 'px_width', 'ram', 'sc_h', 'sc_w', 'talk_time']
categorical = ['blue', 'dual_sim', 'four_g', 'three_g', 'touch_screen', 'wifi']

df = pd.melt(train[categorical])

#numerical attributes
fig = plt.figure(figsize=(15,20))
for i,col in enumerate(numerical):
    ax=plt.subplot(5,3,i+1) 
    train[col].plot.hist(ax = ax).tick_params(axis = 'x',labelrotation = 360)
    ax.legend(loc = 'upper center', bbox_to_anchor=(0.5, 1.1))
plt.show()

skewed = ['clock_speed', 'fc', 'm_dep', 'px_height', 'sc_w']
no_skewed = ['battery_power', 'int_memory', 'mobile_wt', 'n_cores', 'pc', 'px_width', 'ram', 'sc_h', 'talk_time']

#correlation between attributes
corr = train.corr()
fig, (ax) = plt.subplots(1,1,sharey = True, figsize = (20,10))
sns.heatmap(corr, cmap = 'Blues')

#variables with symmetrical distributions
group_no_skewed = train.groupby('price_range')[no_skewed].mean().reset_index()
fig = plt.figure(figsize=(15,20))
for i,col in enumerate(group_no_skewed.iloc[:,1:].columns):
    ax=plt.subplot(5,3,i+1) 
    group_no_skewed.iloc[:,1:][col].plot.bar(ax = ax).tick_params(axis = 'x',labelrotation = 360)
    ax.legend(loc = 'upper center', bbox_to_anchor=(0.5, 1.1))
plt.show()

#variables with skewed distributions
group_skewed = train.groupby('price_range')[skewed].median().reset_index()
fig = plt.figure(figsize=(15,20))
for i,col in enumerate(group_skewed.iloc[:,1:].columns):
    ax=plt.subplot(5,3,i+1) 
    group_skewed.iloc[:,1:][col].plot.bar(ax = ax).tick_params(axis = 'x',labelrotation = 360)
    ax.legend(loc = 'upper center', bbox_to_anchor=(0.5, 1.1))
plt.show()

sns.catplot('price_range', col='three_g', hue='four_g', data=train, kind='count', col_wrap=2)