In [1]:
%matplotlib inline
In [2]:
import pandas_ml as pdml
In [3]:
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (4, 3)
In [4]:
df = pdml.ModelFrame(np.random.randn(100, 5) + np.array([1, 2, 3, 4, 5]),
columns=list('abcde'))
df.target = df['a']
df.head()
Out[4]:
In [5]:
df.target.name
Out[5]:
In [6]:
df.sns.distplot();
You can specify options as the same as the standard seaborn
.
In [7]:
df.sns.distplot(kde=False, rug=True);
In [8]:
df.sns.distplot(bins=20, kde=False, rug=True);
In [9]:
df.sns.distplot(hist=False, rug=True);
Specifying the column name shows distribution of the specified column.
In [10]:
df.sns.distplot('b');
In [11]:
df.sns.kdeplot(shade=True);
In [12]:
df.sns.kdeplot()
df.sns.kdeplot(bw=.2, label="bw: 0.2")
df.sns.kdeplot(bw=2, label="bw: 2")
plt.legend();
In [13]:
df.sns.kdeplot('b', shade=True, cut=0)
df.sns.rugplot('b');
In [14]:
df.sns.jointplot('b', size=4);
If you specify both x
and y
, it will shows the specified columns.
In [15]:
df.sns.jointplot('b', 'c', kind="hex", color="k", size=4);
In [16]:
df.sns.jointplot("d", "e", kind="kde", size=4);
In [17]:
f, ax = plt.subplots()
df.sns.kdeplot('b', 'c', ax=ax)
df.sns.rugplot('b', color="g", ax=ax)
df.sns.rugplot('c', vertical=True, ax=ax);
In [18]:
cmap = df.sns.cubehelix_palette(as_cmap=True, dark=0, light=1, reverse=True)
df.sns.kdeplot('b', 'c', cmap=cmap, n_levels=60, shade=True);
In [19]:
g = df.sns.jointplot(x="a", y="b", kind="kde", color="m", size=4)
g.plot_joint(plt.scatter, c="w", s=30, linewidth=1, marker="+")
g.ax_joint.collections[0].set_alpha(0);
In [20]:
import seaborn as sns
iris = sns.load_dataset("iris")
iris = pdml.ModelFrame(iris, target='species')
iris.head()
Out[20]:
In [21]:
iris.sns.pairplot(size=1.5);
In [22]:
import seaborn as sns
g = iris.sns.PairGrid(size=1.5)
g.map_diag(iris.sns.kdeplot)
g.map_offdiag(iris.sns.kdeplot, cmap="Blues_d", n_levels=6);
In [ ]: