From dab216338f669c50c1739274d5d79725b3de78ff Mon Sep 17 00:00:00 2001 From: sagarrajroul Date: Wed, 9 Dec 2020 13:31:38 +0530 Subject: [PATCH 1/2] Create Readme.md --- intern-basics/House_price_Prediction/Readme.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 intern-basics/House_price_Prediction/Readme.md diff --git a/intern-basics/House_price_Prediction/Readme.md b/intern-basics/House_price_Prediction/Readme.md new file mode 100644 index 0000000..8b8b41b --- /dev/null +++ b/intern-basics/House_price_Prediction/Readme.md @@ -0,0 +1,13 @@ +# House Price Prediction + +In this project, we used some algorithm to predict the house price for boston housing datasets. Main goal is to compare various algorithms and evaluate models by comparing prediction accuracy. We examined different models - Linear Regression, Lasso Regression and RidgeRegression based on the accuracy (MSE) . + +# Algorithms Used + +
  • Linear Regression
  • +
  • Ridge Regression
  • +
  • Lasso Regression
  • + + +# conclusion +We have compared algorithms by MSE. We found that Lasso model gave lowest MSE. From 4a5323bae676b1a5803be3afb86243d8d2960421 Mon Sep 17 00:00:00 2001 From: sagarrajroul Date: Wed, 9 Dec 2020 13:32:20 +0530 Subject: [PATCH 2/2] Add files via upload --- .../House_price_Prediction/boston_house.ipynb | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 intern-basics/House_price_Prediction/boston_house.ipynb diff --git a/intern-basics/House_price_Prediction/boston_house.ipynb b/intern-basics/House_price_Prediction/boston_house.ipynb new file mode 100644 index 0000000..a086e18 --- /dev/null +++ b/intern-basics/House_price_Prediction/boston_house.ipynb @@ -0,0 +1,140 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(506,)" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.datasets import load_boston\n", + "import numpy as np\n", + "\n", + "X, Y = load_boston(return_X_y=True)\n", + "Y.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "37.89377859960245\n", + "[-1.91246374e-01 4.42289967e-02 5.52207977e-02 1.71631351e+00\n", + " -1.49957220e+01 4.88773025e+00 2.60921031e-03 -1.29480799e+00\n", + " 4.84787214e-01 -1.54006673e-02 -8.08795026e-01 -1.29230427e-03\n", + " -5.17953791e-01] 28.67259959085611\n" + ] + } + ], + "source": [ + "###Linear Regression\n", + "from sklearn import linear_model\n", + "from sklearn.metrics import mean_squared_error\n", + "x_train, x_test = (X[:400], X[400:])\n", + "y_train, y_test = (Y[:400], Y[400:])\n", + "\n", + "reg = linear_model.LinearRegression()\n", + "reg.fit(x_train, y_train)\n", + "\n", + "y_pred = reg.predict(x_test)\n", + "print(mean_squared_error(y_pred, y_test))\n", + "print(reg.coef_, reg.intercept_)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "35.364216909603954\n", + "[-1.87190620e-01 4.55998256e-02 2.36903825e-02 1.64050920e+00\n", + " -7.90352445e+00 4.90320713e+00 -2.77137677e-03 -1.20245094e+00\n", + " 4.68016759e-01 -1.63967738e-02 -7.32829766e-01 1.03596933e-03\n", + " -5.28859060e-01]\n", + "23.378443298143104\n" + ] + } + ], + "source": [ + "##Ridge Regression\n", + "ridge = linear_model.Ridge()\n", + "ridge.fit(x_train, y_train)\n", + "\n", + "y_pred_ridge = ridge.predict(x_test)\n", + "print(mean_squared_error(y_pred_ridge, y_test))\n", + "\n", + "print(ridge.coef_)\n", + "print(ridge.intercept_)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "21.668677158204268\n", + "[-0.06672593 0.04867329 -0. 0. -0. 1.8287023\n", + " 0.02662454 -0.73154672 0.36464622 -0.01739047 -0.6456581 0.00861184\n", + " -0.78298032]\n", + "34.36296528131457\n" + ] + } + ], + "source": [ + "##Lasso Regression \n", + "lasso = linear_model.Lasso()\n", + "lasso.fit(x_train, y_train)\n", + "\n", + "y_pred_lasso = lasso.predict(x_test)\n", + "print(mean_squared_error(y_pred_lasso, y_test))\n", + "\n", + "print(lasso.coef_)\n", + "print(lasso.intercept_)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}