Difference makes the DIFFERENCE
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use(['dark_background'])
import seaborn as sns
sns.set(color_codes = True)
t = sns.load_dataset('tips')
t.head(2)
sns.scatterplot(x='tip', y='total_bill', data = t)
sns.scatterplot(x='total_bill', y='tip', data = t)
t.head(2)
sns.scatterplot(x='tip', y='smoker', data = t)
t.groupby(t['smoker']).count()
t.head(2)
sns.scatterplot(x='total_bill', y='size', data=t)
size = t.groupby(['size']).count()
size
sns.scatterplot(x='tip', y='size', data=t)
t.info(); t.describe()
t.head(1)
sns.scatterplot(x='total_bill', y='tip', hue='smoker', data=t)
sns.scatterplot(x='total_bill', y='tip', data = t)
t['frac_tip'] = t['tip']/t['total_bill']
t.head(2)
sns.scatterplot(x='total_bill', y='frac_tip', data = t)
t['tTipFrac'] = (t['tip'] + t['total_bill']) / t['total_bill']
t.head(2)
sns.scatterplot(x = "total_bill", y = 'tTipFrac', data = t)
t.head()
t.drop('tTipFrac', inplace = True, axis=1)
t.head()
sns.scatterplot(x = "total_bill", y = 'tip', data = t, hue = 'time')
sns.scatterplot(x = "total_bill", y = 'tip', data = t, hue = 'sex')
sns.scatterplot(x = "total_bill", y = 'tip', data = t, hue = 'smoker')
sns.scatterplot(x = "total_bill", y = 'tip', data = t, hue = 'day')
sns.scatterplot(x = "total_bill", y = 'tip', data = t, hue = 'size')
sns.scatterplot(x = "total_bill", y = 'tip', data = t, hue = 'time', style='sex')
fig = plt.gcf()
fig.set_size_inches(15, 6)
sns.scatterplot(x = "total_bill", y = 'tip', data = t, hue = 'time', style='sex', size='size')
plt.legend(bbox_to_anchor=(1, 1))
sns.regplot(x = "total_bill", y = 'tip', data = t)
t.head(2)
sns.regplot(x = "total_bill", y = 'frac_tip', data = t)
sns.regplot(x = "total_bill", y = 'tip', data = t, marker="+")
sns.regplot(x = "total_bill", y = 'tip', data = t, marker=".")
d = sns.load_dataset('diamonds')
sns.scatterplot('x', 'price', data = d.sample(1000))
sns.regplot('x', 'price', data = d.sample(1000))
sns.regplot('x', 'price', data = d.sample(1000), order=2)
ds = d.sample(1000)
fig = plt.gcf()
fig.set_size_inches(15, 6)
sns.regplot('x', 'price', data = ds, order = 2, marker="+")
plt.legend(bbox_to_anchor=(1, 1))
fig = plt.gcf()
fig.set_size_inches(15, 6)
sns.regplot('x', 'price', data = ds, order=2)
plt.legend(bbox_to_anchor=(1, 1))
fig = plt.gcf()
fig.set_size_inches(15, 6)
sns.regplot('x', 'price', data = d, order=2)
plt.legend(bbox_to_anchor=(1, 1))
ds = sns.load_dataset("tips")
g = sns.FacetGrid(ds, col="time")
g = sns.FacetGrid(ds, col="time")
g.map(sns.histplot, "tip")
g = sns.FacetGrid(ds, col="sex", hue="smoker")
g.map(sns.scatterplot, "total_bill", "tip", alpha=.7)
g.add_legend()
g = sns.FacetGrid(ds, col="smoker", row='time')
g.map(sns.scatterplot, "total_bill", "tip", alpha=.7)
g.add_legend()
g = sns.FacetGrid(ds, col="day", height=5, aspect=.7)
g.map(sns.barplot, "sex", "total_bill", order=["Male", "Female"])
sns.lmplot(x="size", y="tip", data=ds, x_estimator=np.mean);
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
x = t['tip']
y = t['total_bill']
z = t['size']
ax.set_xlabel("tip")
ax.set_ylabel("total bill")
ax.set_zlabel("size")
ax.scatter(x, y, z)
plt.show()
!pip install nbconvert
%shell jupyter nbconvert --to html /content/testfile.ipynb