diff --git a/q01_plot/build.py b/q01_plot/build.py index 0425964..75121a2 100644 --- a/q01_plot/build.py +++ b/q01_plot/build.py @@ -1,8 +1,25 @@ +# %load q01_plot/build.py +# Default imports import matplotlib.pyplot as plt import seaborn as sns import pandas as pd - -data = pd.read_csv('data/house_prices_multivariate.csv') plt.switch_backend('agg') +data = pd.read_csv('data/house_prices_multivariate.csv') + +# Write your code here: +plot_cols = ['LotArea' ,'GarageArea', 'OpenPorchSF','SalePrice'] + +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=True) + plt.subplot(122) + sns.distplot(data[num_cols[i+1]], hist=True, kde=True) + plt.tight_layout() + plt.show() +plot(plot_cols) + -# Write your code here : diff --git a/q02_plot/build.py b/q02_plot/build.py index 67b4924..f6c8f8e 100644 --- a/q02_plot/build.py +++ b/q02_plot/build.py @@ -1,11 +1,29 @@ +# %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') - +df = pd.read_csv('data/house_prices_multivariate.csv') +#plt.switch_backend('agg') # Write your code here: +plot_cols = ['LotArea', 'GarageArea', 'OpenPorchSF', 'SalePrice'] + +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 = df) + plt.subplot(122) + sns.boxplot(facet, num_cols[i+1],data = df) + plt.tight_layout() + plt.show() + + +plot(plot_cols) + + diff --git a/q03_regression_plot/build.py b/q03_regression_plot/build.py index 2aaf8f6..960478a 100644 --- a/q03_regression_plot/build.py +++ b/q03_regression_plot/build.py @@ -1,16 +1,20 @@ +# %load q03_regression_plot/build.py # Default imports import pandas as pd import seaborn as sns import matplotlib.pyplot as plt +# plt.switch_backend('agg') - -data = pd.read_csv('data/house_prices_multivariate.csv') -plt.switch_backend('agg') +df = pd.read_csv('data/house_prices_multivariate.csv') # Write your code here +def regression_plot(feature1,feature2): + sns.jointplot(feature1, feature2, data=df, kind='reg') + plt.show() + - +regression_plot('GrLivArea','SalePrice') diff --git a/q04_cor/build.py b/q04_cor/build.py index f3fae50..04b4f82 100644 --- a/q04_cor/build.py +++ b/q04_cor/build.py @@ -1,10 +1,21 @@ +# %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(df): + plt.figure(figsize = (8,5)) + sns.heatmap(df.corr(),cmap='viridis') + plt.show() + + + +cor(data) + +