diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc index f93420f..cda4a0b 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..96739d2 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..7f80e8f 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..b5711c7 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 @@ -5,4 +6,10 @@ # 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..54e46a2 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..b979b44 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..f8bc51b 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..60b3618 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..8cbdb91 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,14 @@ # 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..ce2eae6 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..7542d57 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..3224c0a 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..108d578 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..ada3167 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 @@ -7,4 +8,13 @@ # Write your code here : +def linear_regression(X,y): + reg = LinearRegression() + lm = reg.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..a6e5a9d 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..af4fe01 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..773387f 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..7bdb735 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..e327153 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 @@ -8,7 +9,18 @@ dataframe = load_data('data/house_prices_multivariate.csv') X, y = data_splitter(dataframe) -linear_model = linear_regression(X, y) +lm = linear_regression(X, y) # Your code here +def linear_predictor(lm ,X,y): + y_pred = lm.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(lm,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..e5919d8 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..9434587 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..7506e0d 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..0a837fd 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..ebfbe1e 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_residual = y - y_pred + return error_residual + +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..2a8560c 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..84d5139 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..368a238 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..f7daa47 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..8f5ec50 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 @@ -16,4 +17,15 @@ # Your code here +def plot_residuals(y,error_residuals): + plt.scatter(y,error_residuals,color = 'blue') + plt.title('Residual plot') + plt.xlabel('sales Price') + 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..51dbb20 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..e4aa212 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..0be0585 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..21d9d9a 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..ba2f4d5 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,8 @@ 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..2ecd078 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..d780023 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..29a4c7c 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..aca2605 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..9e945d4 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,12 @@ # 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..772878b 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..0a66f96 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