xxxxxxxxxx
import pandas as pd,numpy as np,pylab as pl
colors=['#3636ff','#ff3636','#36ff36',
'#ff36ff','#ffff36','#36ffff']
user='https://raw.githubusercontent.com/OlgaBelitskaya/'
path='machine_learning_engineer_nd009/'+\
'master/Machine_Learning_Engineer_ND_P3/'
data=pd.read_csv(user+path+'customers.csv')
fig=pl.figure(figsize=(6,6))
ax1=fig.add_subplot(2,1,1)
params={'frame':data,'class_column':'Channel',
'lw':.5,'color':colors}
pd.plotting.andrews_curves(**params,ax=ax1)
ax2=fig.add_subplot(2,1,2)
pd.plotting.parallel_coordinates(**params,ax=ax2)
pl.show()
xxxxxxxxxx
pl.figure(figsize=(6,4))
pd.plotting.radviz(**params,s=3)
pl.xticks([]); pl.yticks([]); pl.show()
xxxxxxxxxx
data[data<5000].drop('Region',axis=1)\
.boxplot(by='Channel',figsize=(6,6),
boxprops={'color':colors[0]},
flierprops={'markerfacecolor':colors[1]});
pl.show()
xxxxxxxxxx
data[data<10000].plot.hexbin(
x='Fresh',y='Milk',C='Grocery',
reduce_C_function=np.mean,gridsize=20,
cmap='Spectral',figsize=(6,4))
pl.show()
xxxxxxxxxx
fig=pl.figure(figsize=(6,4))
ax=fig.add_subplot(1,1,1)
data.iloc[:,int(1):].plot.area(
stacked=False,ax=ax,cmap='Spectral')
data_mean=pd.DataFrame(
data.iloc[:,int(1):].mean().round()).T
data_mean.index=['mean']
pd.plotting.table(ax,data_mean,loc='top')
pl.grid(); pl.show()
xxxxxxxxxx
data0=data.drop('Region',axis=1).groupby('Channel').sum().T
data0.columns=['Channel 1','Channel 2']
data0.plot.pie(
subplots=True,layout=(2,1),figsize=(3,6),legend=False,cmap='bwr')
pl.show()
xxxxxxxxxx
data_range=data.iloc[:,int(2):]\
[(data<5000.)&(data>1000.)]
params={'bins':int(80),'alpha':.5,
'figsize':(6,4),'color':colors}
data_range.iloc[:,:int(3)].plot.hist(**params)
pl.show()
data_range.iloc[:,int(3):].plot.hist(**params)
pl.show()
No comments:
Post a Comment