diff --git a/q01_plot/build.py b/q01_plot/build.py index 0425964..ec4db4d 100644 --- a/q01_plot/build.py +++ b/q01_plot/build.py @@ -1,8 +1,29 @@ +# %load q01_plot/build.py +# Default imports import matplotlib.pyplot as plt +plt.switch_backend('agg') import seaborn as sns import pandas as pd data = pd.read_csv('data/house_prices_multivariate.csv') -plt.switch_backend('agg') -# Write your code here : +# Write your code here: + +def plot(num_cols): + fig, axes = plt.subplots(2, 2,) + axes[0, 0].hist(data.LotArea,) + axes[0, 1].hist(data.GarageArea) + axes[1, 0].hist(data.OpenPorchSF) + axes[1, 1].hist(data.SalePrice) + plt.show() +plt.hist(data.GarageArea,bins=20) +fig, axes = plt.subplots(2, 2,) +axes[0, 0].hist(data.LotArea,) +axes[0, 1].hist(data.GarageArea) +axes[1, 0].hist(data.OpenPorchSF) +axes[1, 1].hist(data.SalePrice) +plt.show() +from inspect import getfullargspec +getfullargspec(plot) + + diff --git a/q02_plot/build.py b/q02_plot/build.py index 67b4924..9622b7a 100644 --- a/q02_plot/build.py +++ b/q02_plot/build.py @@ -1,11 +1,36 @@ +# %load q02_plot/build.py # Default imports import pandas as pd import matplotlib.pyplot as plt +plt.switch_backend('agg') import seaborn as sns data = pd.read_csv('data/house_prices_multivariate.csv') -plt.switch_backend('agg') # Write your code here: +def plot(num_cols): + _, args=plt.subplots(2,2) + if num_cols>0: + args[0,0].boxplot(data.LotArea) + if num_cols>1: + args[0,1].boxplot(data.GarageArea) + if num_cols>2: + args[1,0].boxplot(data.OpenPorchSF) + if num_cols>3: + args[1,1].boxplot(data.SalePrice) + +plt.boxplot(data.GarageArea) +num_cols=10 +_, args=plt.subplots(2,2) +if num_cols>0: + args[0,0].boxplot(data.LotArea) +if num_cols>1: + args[0,1].boxplot(data.GarageArea) +if num_cols>2: + args[1,0].boxplot(data.OpenPorchSF) +if num_cols>3: + args[1,1].boxplot(data.SalePrice) +plot(5) + diff --git a/q03_regression_plot/build.py b/q03_regression_plot/build.py index 2aaf8f6..6cf8528 100644 --- a/q03_regression_plot/build.py +++ b/q03_regression_plot/build.py @@ -1,16 +1,23 @@ +# %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') # Write your code here +def regression_plot(var1,var2): + sns.lmplot(x=var1,y=var2,data=data) + + +sns.lmplot(x='SalePrice',y='GrLivArea',data=data) +regression_plot('SalePrice','GrLivArea') diff --git a/q04_cor/build.py b/q04_cor/build.py index f3fae50..a9e247c 100644 --- a/q04_cor/build.py +++ b/q04_cor/build.py @@ -1,10 +1,19 @@ +# %load q04_cor/build.py # Default imports import pandas as pd import matplotlib.pyplot as plt +plt.switch_backend('agg') import seaborn as sns data = pd.read_csv('data/house_prices_multivariate.csv') -plt.switch_backend('agg') # Write your code here +def cor(data): + sns.heatmap(data.corr()) + + +data.corr() +sns.heatmap(data.corr()) + +