diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc index f93420f..1e877e3 100644 Binary files a/__pycache__/__init__.cpython-36.pyc and b/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_load_data/__pycache__/__init__.cpython-36.pyc b/q01_load_data/__pycache__/__init__.cpython-36.pyc index 29d3927..eda8276 100644 Binary files a/q01_load_data/__pycache__/__init__.cpython-36.pyc and b/q01_load_data/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_load_data/__pycache__/build.cpython-36.pyc b/q01_load_data/__pycache__/build.cpython-36.pyc index ef1e203..ea7bb65 100644 Binary files a/q01_load_data/__pycache__/build.cpython-36.pyc and b/q01_load_data/__pycache__/build.cpython-36.pyc differ diff --git a/q01_load_data/build.py b/q01_load_data/build.py index 1fea6ca..e410a7d 100644 --- a/q01_load_data/build.py +++ b/q01_load_data/build.py @@ -1,3 +1,4 @@ +# %load q01_load_data/build.py # Default imports import pandas as pd @@ -6,3 +7,11 @@ # Write your code here : +def load_data(path): + df= pd.read_csv(path) + return df + +load_data(path) + + + diff --git a/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc b/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc index b882452..0cd4051 100644 Binary files a/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc and b/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_load_data/tests/__pycache__/test_q01_load_data.cpython-36.pyc b/q01_load_data/tests/__pycache__/test_q01_load_data.cpython-36.pyc index 736de76..3e0b7cd 100644 Binary files a/q01_load_data/tests/__pycache__/test_q01_load_data.cpython-36.pyc and b/q01_load_data/tests/__pycache__/test_q01_load_data.cpython-36.pyc differ diff --git a/q02_data_splitter/__pycache__/__init__.cpython-36.pyc b/q02_data_splitter/__pycache__/__init__.cpython-36.pyc index 67f0b61..df391c8 100644 Binary files a/q02_data_splitter/__pycache__/__init__.cpython-36.pyc and b/q02_data_splitter/__pycache__/__init__.cpython-36.pyc differ diff --git a/q02_data_splitter/__pycache__/build.cpython-36.pyc b/q02_data_splitter/__pycache__/build.cpython-36.pyc index 412515b..860b1f7 100644 Binary files a/q02_data_splitter/__pycache__/build.cpython-36.pyc and b/q02_data_splitter/__pycache__/build.cpython-36.pyc differ diff --git a/q02_data_splitter/build.py b/q02_data_splitter/build.py index cf517fe..2bccc77 100644 --- a/q02_data_splitter/build.py +++ b/q02_data_splitter/build.py @@ -1,3 +1,4 @@ +# %load q02_data_splitter/build.py # Default Imports from greyatomlib.linear_regression.q01_load_data.build import load_data import pandas as pd @@ -5,4 +6,11 @@ # Your Code Here +def data_splitter(df): + X = df.iloc[:,:-1] + y = df.SalePrice + return X,y +data_splitter(df) + + diff --git a/q02_data_splitter/tests/__pycache__/__init__.cpython-36.pyc b/q02_data_splitter/tests/__pycache__/__init__.cpython-36.pyc index e7e9527..f7b5778 100644 Binary files a/q02_data_splitter/tests/__pycache__/__init__.cpython-36.pyc and b/q02_data_splitter/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q02_data_splitter/tests/__pycache__/test_q02_data_splitter.cpython-36.pyc b/q02_data_splitter/tests/__pycache__/test_q02_data_splitter.cpython-36.pyc index db949a7..83c46f6 100644 Binary files a/q02_data_splitter/tests/__pycache__/test_q02_data_splitter.cpython-36.pyc and b/q02_data_splitter/tests/__pycache__/test_q02_data_splitter.cpython-36.pyc differ diff --git a/q03_linear_regression/__pycache__/__init__.cpython-36.pyc b/q03_linear_regression/__pycache__/__init__.cpython-36.pyc index b8f4cc0..01b15b5 100644 Binary files a/q03_linear_regression/__pycache__/__init__.cpython-36.pyc and b/q03_linear_regression/__pycache__/__init__.cpython-36.pyc differ diff --git a/q03_linear_regression/__pycache__/build.cpython-36.pyc b/q03_linear_regression/__pycache__/build.cpython-36.pyc index d3a347e..88d9c8e 100644 Binary files a/q03_linear_regression/__pycache__/build.cpython-36.pyc and b/q03_linear_regression/__pycache__/build.cpython-36.pyc differ diff --git a/q03_linear_regression/build.py b/q03_linear_regression/build.py index 03ab5ff..9121840 100644 --- a/q03_linear_regression/build.py +++ b/q03_linear_regression/build.py @@ -1,3 +1,4 @@ +# %load q03_linear_regression/build.py from greyatomlib.linear_regression.q01_load_data.build import load_data from greyatomlib.linear_regression.q02_data_splitter.build import data_splitter from sklearn.linear_model import LinearRegression @@ -6,5 +7,13 @@ X, y = data_splitter(dataframe) # Write your code here : +def linear_regression(X,y): + regressor = LinearRegression() + lm = regressor.fit(X , y) + return lm +linear_regression(X,y) + + + diff --git a/q03_linear_regression/tests/__pycache__/__init__.cpython-36.pyc b/q03_linear_regression/tests/__pycache__/__init__.cpython-36.pyc index 739e010..f721704 100644 Binary files a/q03_linear_regression/tests/__pycache__/__init__.cpython-36.pyc and b/q03_linear_regression/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q03_linear_regression/tests/__pycache__/test_q03_linear_regression.cpython-36.pyc b/q03_linear_regression/tests/__pycache__/test_q03_linear_regression.cpython-36.pyc index fe5fba5..865beb1 100644 Binary files a/q03_linear_regression/tests/__pycache__/test_q03_linear_regression.cpython-36.pyc and b/q03_linear_regression/tests/__pycache__/test_q03_linear_regression.cpython-36.pyc differ diff --git a/q04_linear_predictor/__pycache__/__init__.cpython-36.pyc b/q04_linear_predictor/__pycache__/__init__.cpython-36.pyc index 3c623bd..97f2075 100644 Binary files a/q04_linear_predictor/__pycache__/__init__.cpython-36.pyc and b/q04_linear_predictor/__pycache__/__init__.cpython-36.pyc differ diff --git a/q04_linear_predictor/__pycache__/build.cpython-36.pyc b/q04_linear_predictor/__pycache__/build.cpython-36.pyc index 2e68f8e..cbaf24d 100644 Binary files a/q04_linear_predictor/__pycache__/build.cpython-36.pyc and b/q04_linear_predictor/__pycache__/build.cpython-36.pyc differ diff --git a/q04_linear_predictor/build.py b/q04_linear_predictor/build.py index e3c8357..d916fe7 100644 --- a/q04_linear_predictor/build.py +++ b/q04_linear_predictor/build.py @@ -1,3 +1,4 @@ +# %load q04_linear_predictor/build.py # Default Imports from greyatomlib.linear_regression.q01_load_data.build import load_data from greyatomlib.linear_regression.q02_data_splitter.build import data_splitter @@ -12,3 +13,14 @@ # Your code here +def linear_predictor(linear_model,X, y): + y_pred = linear_model.predict(X) + mse = mean_squared_error(y, y_pred) + mae = mean_absolute_error(y,y_pred) + r2 = r2_score(y, y_pred) + return y_pred, mse, mae, r2 +linear_predictor(linear_model, X,y) + + + + diff --git a/q04_linear_predictor/tests/__pycache__/__init__.cpython-36.pyc b/q04_linear_predictor/tests/__pycache__/__init__.cpython-36.pyc index 8abd4d2..b486cf4 100644 Binary files a/q04_linear_predictor/tests/__pycache__/__init__.cpython-36.pyc and b/q04_linear_predictor/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q04_linear_predictor/tests/__pycache__/test_q04_linear_predictor.cpython-36.pyc b/q04_linear_predictor/tests/__pycache__/test_q04_linear_predictor.cpython-36.pyc index 7b2e751..3d12fd7 100644 Binary files a/q04_linear_predictor/tests/__pycache__/test_q04_linear_predictor.cpython-36.pyc and b/q04_linear_predictor/tests/__pycache__/test_q04_linear_predictor.cpython-36.pyc differ diff --git a/q05_residuals/__pycache__/__init__.cpython-36.pyc b/q05_residuals/__pycache__/__init__.cpython-36.pyc index 82a3d44..a4ff54b 100644 Binary files a/q05_residuals/__pycache__/__init__.cpython-36.pyc and b/q05_residuals/__pycache__/__init__.cpython-36.pyc differ diff --git a/q05_residuals/__pycache__/build.cpython-36.pyc b/q05_residuals/__pycache__/build.cpython-36.pyc index 73e9d89..957e518 100644 Binary files a/q05_residuals/__pycache__/build.cpython-36.pyc and b/q05_residuals/__pycache__/build.cpython-36.pyc differ diff --git a/q05_residuals/build.py b/q05_residuals/build.py index aaef679..702d9a0 100644 --- a/q05_residuals/build.py +++ b/q05_residuals/build.py @@ -1,3 +1,4 @@ +# %load q05_residuals/build.py # Default Imports from greyatomlib.linear_regression.q01_load_data.build import load_data from greyatomlib.linear_regression.q02_data_splitter.build import data_splitter @@ -12,3 +13,10 @@ # Your code here +def residuals(y, y_pred): + error_residuals = y - y_pred + return error_residuals +residuals(y, y_pred) + + + diff --git a/q05_residuals/tests/__pycache__/__init__.cpython-36.pyc b/q05_residuals/tests/__pycache__/__init__.cpython-36.pyc index 95e65cc..cdee486 100644 Binary files a/q05_residuals/tests/__pycache__/__init__.cpython-36.pyc and b/q05_residuals/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q05_residuals/tests/__pycache__/test_q05_residuals.cpython-36.pyc b/q05_residuals/tests/__pycache__/test_q05_residuals.cpython-36.pyc index 4263cb0..1d9d6d7 100644 Binary files a/q05_residuals/tests/__pycache__/test_q05_residuals.cpython-36.pyc and b/q05_residuals/tests/__pycache__/test_q05_residuals.cpython-36.pyc differ diff --git a/q06_plot_residuals/__pycache__/__init__.cpython-36.pyc b/q06_plot_residuals/__pycache__/__init__.cpython-36.pyc index cbab384..67d3958 100644 Binary files a/q06_plot_residuals/__pycache__/__init__.cpython-36.pyc and b/q06_plot_residuals/__pycache__/__init__.cpython-36.pyc differ diff --git a/q06_plot_residuals/__pycache__/build.cpython-36.pyc b/q06_plot_residuals/__pycache__/build.cpython-36.pyc index 67ae5f6..e89d052 100644 Binary files a/q06_plot_residuals/__pycache__/build.cpython-36.pyc and b/q06_plot_residuals/__pycache__/build.cpython-36.pyc differ diff --git a/q06_plot_residuals/build.py b/q06_plot_residuals/build.py index cfd3722..9012718 100644 --- a/q06_plot_residuals/build.py +++ b/q06_plot_residuals/build.py @@ -1,3 +1,4 @@ +# %load q06_plot_residuals/build.py # Default Imports from greyatomlib.linear_regression.q01_load_data.build import load_data from greyatomlib.linear_regression.q02_data_splitter.build import data_splitter @@ -17,3 +18,14 @@ # Your code here +def plot_residuals(y, error_residuals): + plt.scatter(y,error_residuals) + plt.title('Residual Plot') + plt.xlabel('SalePrice') + plt.ylabel('Error') + plt.show() + return +plot_residuals(y, error_residuals) + + + diff --git a/q06_plot_residuals/tests/__pycache__/__init__.cpython-36.pyc b/q06_plot_residuals/tests/__pycache__/__init__.cpython-36.pyc index 3ce3f60..ce23e0c 100644 Binary files a/q06_plot_residuals/tests/__pycache__/__init__.cpython-36.pyc and b/q06_plot_residuals/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q06_plot_residuals/tests/__pycache__/test_q06_plot_residuals.cpython-36.pyc b/q06_plot_residuals/tests/__pycache__/test_q06_plot_residuals.cpython-36.pyc index 5f787c4..acf4df4 100644 Binary files a/q06_plot_residuals/tests/__pycache__/test_q06_plot_residuals.cpython-36.pyc and b/q06_plot_residuals/tests/__pycache__/test_q06_plot_residuals.cpython-36.pyc differ diff --git a/q07_hist_residuals/__pycache__/__init__.cpython-36.pyc b/q07_hist_residuals/__pycache__/__init__.cpython-36.pyc index 4823574..5d03d87 100644 Binary files a/q07_hist_residuals/__pycache__/__init__.cpython-36.pyc and b/q07_hist_residuals/__pycache__/__init__.cpython-36.pyc differ diff --git a/q07_hist_residuals/__pycache__/build.cpython-36.pyc b/q07_hist_residuals/__pycache__/build.cpython-36.pyc index e030b2b..e8c0409 100644 Binary files a/q07_hist_residuals/__pycache__/build.cpython-36.pyc and b/q07_hist_residuals/__pycache__/build.cpython-36.pyc differ diff --git a/q07_hist_residuals/build.py b/q07_hist_residuals/build.py index 2f999aa..f525ce6 100644 --- a/q07_hist_residuals/build.py +++ b/q07_hist_residuals/build.py @@ -1,3 +1,4 @@ +# %load q07_hist_residuals/build.py # Default Imports from greyatomlib.linear_regression.q01_load_data.build import load_data from greyatomlib.linear_regression.q02_data_splitter.build import data_splitter @@ -19,3 +20,9 @@ def hist_residuals(error_residuals, bins=60): plt.figure(figsize=(15,8)) plt.hist(error_residuals, bins=bins) + return + +hist_residuals(error_residuals, bins=60) + + + diff --git a/q07_hist_residuals/tests/__pycache__/__init__.cpython-36.pyc b/q07_hist_residuals/tests/__pycache__/__init__.cpython-36.pyc index f7acf95..dab9a5f 100644 Binary files a/q07_hist_residuals/tests/__pycache__/__init__.cpython-36.pyc and b/q07_hist_residuals/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q07_hist_residuals/tests/__pycache__/test_q07_hist_residuals.cpython-36.pyc b/q07_hist_residuals/tests/__pycache__/test_q07_hist_residuals.cpython-36.pyc index 3919c93..b112e6e 100644 Binary files a/q07_hist_residuals/tests/__pycache__/test_q07_hist_residuals.cpython-36.pyc and b/q07_hist_residuals/tests/__pycache__/test_q07_hist_residuals.cpython-36.pyc differ diff --git a/q08_qq_residuals/__pycache__/__init__.cpython-36.pyc b/q08_qq_residuals/__pycache__/__init__.cpython-36.pyc index 8069022..bcd8c1e 100644 Binary files a/q08_qq_residuals/__pycache__/__init__.cpython-36.pyc and b/q08_qq_residuals/__pycache__/__init__.cpython-36.pyc differ diff --git a/q08_qq_residuals/__pycache__/build.cpython-36.pyc b/q08_qq_residuals/__pycache__/build.cpython-36.pyc index d42be94..7cc3246 100644 Binary files a/q08_qq_residuals/__pycache__/build.cpython-36.pyc and b/q08_qq_residuals/__pycache__/build.cpython-36.pyc differ diff --git a/q08_qq_residuals/build.py b/q08_qq_residuals/build.py index bb05f08..df7f8d5 100644 --- a/q08_qq_residuals/build.py +++ b/q08_qq_residuals/build.py @@ -1,3 +1,4 @@ +# %load q08_qq_residuals/build.py # Default Imports from greyatomlib.linear_regression.q01_load_data.build import load_data from greyatomlib.linear_regression.q02_data_splitter.build import data_splitter @@ -20,3 +21,11 @@ # Your code here +def qq_residuals(error_residuals): + stats.probplot(error_residuals, dist= 'norm', plot=pylab) + pylab.show() + return + +qq_residuals(error_residuals) + + diff --git a/q08_qq_residuals/tests/__pycache__/__init__.cpython-36.pyc b/q08_qq_residuals/tests/__pycache__/__init__.cpython-36.pyc index 320d34e..78c4e8d 100644 Binary files a/q08_qq_residuals/tests/__pycache__/__init__.cpython-36.pyc and b/q08_qq_residuals/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q08_qq_residuals/tests/__pycache__/test_q08_qq_residuals.cpython-36.pyc b/q08_qq_residuals/tests/__pycache__/test_q08_qq_residuals.cpython-36.pyc index bc94040..2fef936 100644 Binary files a/q08_qq_residuals/tests/__pycache__/test_q08_qq_residuals.cpython-36.pyc and b/q08_qq_residuals/tests/__pycache__/test_q08_qq_residuals.cpython-36.pyc differ