From 40b653095d634903716c57a8de48afb6412c5361 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Sun, 18 Nov 2018 04:24:19 +0000 Subject: [PATCH 1/4] Done --- q01_plot/build.py | 20 ++++++++++++++++++-- q02_plot/build.py | 19 +++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/q01_plot/build.py b/q01_plot/build.py index 0425964..51e7ebc 100644 --- a/q01_plot/build.py +++ b/q01_plot/build.py @@ -1,8 +1,24 @@ +# %load q01_plot/build.py +# Default imports import matplotlib.pyplot as plt import seaborn as sns import pandas as pd +plt.switch_backend('agg') data = pd.read_csv('data/house_prices_multivariate.csv') -plt.switch_backend('agg') -# Write your code here : +num_cols = ['LotArea', 'GarageArea', 'OpenPorchSF', 'SalePrice'] +# Write your code here: +def plot(num_cols): + for i in range(0,len(num_cols),2): + if len(num_cols) > i+1: + plt.figure(figsize=(10,4)) + plt.subplot(121) + sns.distplot(data[num_cols[i]], hist=True, kde=False) + plt.subplot(122) + sns.distplot(data[num_cols[i+1]], hist=True, kde=False) + plt.tight_layout() + plt.show() + +plot(num_cols) + diff --git a/q02_plot/build.py b/q02_plot/build.py index 67b4924..f5b8550 100644 --- a/q02_plot/build.py +++ b/q02_plot/build.py @@ -1,11 +1,26 @@ +# %load q02_plot/build.py # Default imports import pandas as pd import matplotlib.pyplot as plt import seaborn as sns data = pd.read_csv('data/house_prices_multivariate.csv') -plt.switch_backend('agg') - +num_cols = ['LotArea', 'GarageArea', 'OpenPorchSF', 'SalePrice'] # Write your code here: +def plot(num_cols): + facet = None + for i in range(0,len(num_cols),2): + if len(num_cols) > i+1: + plt.figure(figsize=(10,4)) + plt.subplot(121) + sns.boxplot(facet, num_cols[i],data = data) + plt.subplot(122) + sns.boxplot(facet, num_cols[i+1],data = data) + plt.tight_layout() + plt.show() + + else: + sns.boxplot(facet, num_cols[i],data = data) +plot(num_cols) From 6be15f49fe7cba32fb99a727849d5c838dc3d9b9 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Sun, 18 Nov 2018 04:26:14 +0000 Subject: [PATCH 2/4] Done --- q02_plot/build.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/q02_plot/build.py b/q02_plot/build.py index f5b8550..2a147d1 100644 --- a/q02_plot/build.py +++ b/q02_plot/build.py @@ -3,6 +3,7 @@ import pandas as pd import matplotlib.pyplot as plt import seaborn as sns +plt.switch_backend('agg') data = pd.read_csv('data/house_prices_multivariate.csv') num_cols = ['LotArea', 'GarageArea', 'OpenPorchSF', 'SalePrice'] @@ -19,8 +20,5 @@ def plot(num_cols): sns.boxplot(facet, num_cols[i+1],data = data) plt.tight_layout() plt.show() - - else: - sns.boxplot(facet, num_cols[i],data = data) plot(num_cols) From b8deb3bf5399437f9280285fe53abb31c8553700 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Thu, 29 Nov 2018 18:10:37 +0000 Subject: [PATCH 3/4] Done --- q03_regression_plot/build.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/q03_regression_plot/build.py b/q03_regression_plot/build.py index 2aaf8f6..bf10cb8 100644 --- a/q03_regression_plot/build.py +++ b/q03_regression_plot/build.py @@ -1,16 +1,18 @@ +# %load q03_regression_plot/build.py # Default imports import pandas as pd import seaborn as sns import matplotlib.pyplot as plt - - -data = pd.read_csv('data/house_prices_multivariate.csv') plt.switch_backend('agg') +data = pd.read_csv('data/house_prices_multivariate.csv') +x = data['GrLivArea'] +y = data['SalePrice'] # Write your code here - - - +def regression_plot(x,y): + sns.lmplot('GrLivArea', 'SalePrice', data=data, fit_reg=True) + +regression_plot(x,y) From 7175b623263db7bcbad742f0f464950af35cc376 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Thu, 29 Nov 2018 18:13:31 +0000 Subject: [PATCH 4/4] Done --- q04_cor/build.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/q04_cor/build.py b/q04_cor/build.py index f3fae50..b9e56b6 100644 --- a/q04_cor/build.py +++ b/q04_cor/build.py @@ -1,10 +1,17 @@ +# %load q04_cor/build.py # Default imports import pandas as pd import matplotlib.pyplot as plt import seaborn as sns +plt.switch_backend('agg') data = pd.read_csv('data/house_prices_multivariate.csv') -plt.switch_backend('agg') # Write your code here +def cor(data): + plt.figure(figsize=(12,8)) + sns.heatmap(data.corr(), cmap='viridis') + +cor(data) +