{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "source": [ "In this little experiment we'll see 3 cases of linear regression model and we'll see the value of bias and variance that we will obtain. The 3 cases are:\n", "\n", "\n", "\n", "* data with no noise\n", "* data with a little bit of noise\n", "* data with no relation between X and Y" ], "metadata": { "id": "NjjaAH_-aXIo" } }, { "cell_type": "markdown", "source": [ "# First case: data with no noise" ], "metadata": { "id": "o8gYORtVbTXO" } }, { "cell_type": "code", "execution_count": 58, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 304 }, "id": "5PK0fCwyQwsd", "outputId": "1fb56bef-21ec-4f4e-b205-e5df37ee458a" }, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAD8CAYAAACW/ATfAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3deXxU1f3/8deHJJAIGARBBUSiBTQCAoZFqYKCbFJRkG/BWsWN4rd0caFCbRFcfqDwVb8uFdG61gW/VCktm4ogVGQJi6yiFFASUBAEVBZJcn5/TJjMDFmGMJk7y/v5ePBwzr13Zj7eR3hzcu6555pzDhERSWzVvC5ARESqnsJeRCQJKOxFRJKAwl5EJAko7EVEkoDCXkQkCVQY9mb2gpntNLO1Zew3M3vCzDaZ2Wozaxf5MkVE5ESE07N/CehVzv7eQLPiP0OBZ068LBERiaQKw945twDYU84h/YBXnM9ioI6ZnRGpAkVE5MSlRuAzGgHbAtp5xdt2hB5oZkPx9f6pWbPmheeee24Evl5EJHksX778G+dc/eN9XyTCPmzOucnAZICcnByXm5sbza8XEYl7ZvZFZd4Xidk4+cC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enRIXnwszaAs/iC/pEHZeFCs6Fc26fc+5U51xT51xTfNcvrnLOVWoBqBgXzt+Rafh69ZjZqfiGdTZHs8goCedcfAl0AzCz8/CF/a6oVhkbpgM3FM/K6QTsc87tKO8NVTqM47Sujl+Y52ICUAv4v+Jr1F86567yrOgqEua5SAphnos5QA8zWw8UAiOccwn322+Y5+Iu4DkzuwPfxdohidg5NLM38P0Df2rx9Yn7gDQA59wkfNcr+gCbgAPATRV+ZgKeJxERCaE7aEVEkoDCXkQkCSjsRUSSgMJeRCQJKOxFRJKAwl5EJAko7EVEksD/B10EyygBxOkYAAAAAElFTkSuQmCC\n" }, "metadata": { "needs_background": "light" } }, { "output_type": "stream", "name": "stdout", "text": [ "Bias: 1.0845392999330622e-32\n", "Variance: 0.04953967957663739\n" ] } ], "source": [ "# importation of the necessary libraries\n", "from sklearn.linear_model import LinearRegression\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.metrics import mean_squared_error\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "# data generation (X and y match perfectly)\n", "X = np.random.rand(100, 1)\n", "y = X\n", "\n", "# division of the data into training set and test set\n", "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", "\n", "# training the linear regression model\n", "reg = LinearRegression().fit(X_train, y_train)\n", "\n", "# prevision on test set\n", "y_pred = reg.predict(X_test)\n", "\n", "# calculation of mse\n", "mse = mean_squared_error(y_test, y_pred)\n", "\n", "# calculation of bias and variance\n", "bias = np.mean((y_test - y_pred)**2)\n", "variance = np.var(y_pred)\n", "\n", "# graph of the linear regression\n", "plt.scatter(X_test, y_test, label=\"True value\")\n", "plt.plot(X_test, y_pred, label=\"Prediction\")\n", "plt.legend()\n", "plt.show()\n", "\n", "# result\n", "print(\"Bias:\", bias)\n", "print(\"Variance:\", variance)\n" ] }, { "cell_type": "markdown", "source": [ "Wee can see that bias and variance are really small (bias is close to zero or is zero). This make sense since X and y have perfect linear relationship" ], "metadata": { "id": "VogMeevOc2I3" } }, { "cell_type": "markdown", "source": [ "# Second case: data with a little bit of noise" ], "metadata": { "id": "W9kkXchUfTrt" } }, { "cell_type": "code", "source": [ "# importation of the necessary libraries\n", "from sklearn.linear_model import LinearRegression\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.metrics import mean_squared_error\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "# data generation (y has some noise)\n", "X = np.random.rand(100, 1)\n", "y = X + (np.random.rand(100, 1)/2)\n", "\n", "# division of the data into training set and test set\n", "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", "\n", "# training the linear regression model\n", "reg = LinearRegression().fit(X_train, y_train)\n", "\n", "# prevision on test set\n", "y_pred = reg.predict(X_test)\n", "\n", "# calculation of mse\n", "mse = mean_squared_error(y_test, y_pred)\n", "\n", "# calculation of bias and variance\n", "bias = np.mean((y_test - y_pred)**2)\n", "variance = np.var(y_pred)\n", "\n", "# graph of the linear regression\n", "plt.scatter(X_test, y_test, label=\"True value\")\n", "plt.plot(X_test, y_pred, label=\"Prediction\")\n", "plt.legend()\n", "plt.show()\n", "\n", "# result\n", "print(\"Bias:\", bias)\n", "print(\"Variance:\", variance)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 300 }, "id": "ulA3oNBmdZcF", "outputId": "878b5719-1580-4c1a-e514-cbb47c360c44" }, "execution_count": 57, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3dfZyVc/7H8denKRWl+1BTZlAxJVOmQpJIEyL3GxZZSVbLz/5ELZL73K7bldZisUs2pP1VQkqUaGrSzSSiaCpKt3Q/M9/f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EpwLfAEcABwJdARrlj/giMKfl6ADDO6749Ph+9gANLvr4+2c9HyXH1gZnAHCDL6749/v1oA+QCjUoeN/e6bw/PxVjg+pKvM4CVXvcdzX/xcIXeFVjunPvOObcbeAPoX+6Y/sA/S74eD5xuZhbDHmOp0vPhnJvunNte8nAOkBrjHmMpnN8PgHuBh4CdsWzOA+Gcj2uBZ51zmwCcc+ti3GOshHMuHHBwydcNgDUx7C/m4iHQWwKryjzOL6mFPMY5VwBsAZrEpLvYC+d8lHUNMCWqHXmr0vNhZp2BVs65SbFszCPh/H60Bdqa2Swzm2NmfWPWXWyFcy5GAb83s3xgMvCn2LTmjYTasUgCmdnvgSygp9e9eMXMagCPAwM9biWe1KR42OVUiv96m2lmxzrnNnvalTcuBV52zj1mZicCr5pZB+dckdeNRUM8XKGvBlqVeZxaUgt5jJnVpPhPpw0x6S72wjkfmFlv4HbgXOfcrhj15oXKzkd9oAMww8xWAicAE338wWg4vx/5wETn3B7n3Arga4oD3m/CORfXAG8COOc+A+pQvGiXL8VDoM8F2phZupkdQPGHnhPLHTMRuKrk64uAj1zJpxw+VOn5MLNOwPMUh7lfx0f3qvB8OOe2OOeaOufSnHNpFH+mcK5zLsebdqMunP9eJlB8dY6ZNaV4COa7WDYZI+Gcix+A0wHM7BiKA319TLuMIc8DvWRMfCgwFVgKvOmcW2Jm95jZuSWH/QNoYmbLgT8D+5y6lujCPB+PAPWA/5jZAjMr/0vsG2Gej6QR5vmYCmwwszxgOjDMOee7v2jDPBf/C1xrZl8CrwMDfXwxqFv/RUT8wvMrdBERiQwFuoiITyjQRUR8QoEuIuITCnQREZ9QoIuI+IQCXUTEJ/4f7bWXd0T8axYAAAAASUVORK5CYII=\n" }, "metadata": { "needs_background": "light" } }, { "output_type": "stream", "name": "stdout", "text": [ "Bias: 0.022212543739010212\n", "Variance: 0.08728939726794703\n" ] } ] }, { "cell_type": "markdown", "source": [ "In this case we have an heigher bias because the prediction doesn't match perfectly the true values" ], "metadata": { "id": "VDZ69tAJgv4D" } }, { "cell_type": "markdown", "source": [ "# Third case: data with no relation between X and Y" ], "metadata": { "id": "G8Ue_MJ1gopb" } }, { "cell_type": "code", "source": [ "# importation of the necessary libraries\n", "from sklearn.linear_model import LinearRegression\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.metrics import mean_squared_error\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "# data generation (X and y has no relation between them)\n", "X = np.random.rand(100, 1)\n", "y = (np.random.rand(100, 1))\n", "\n", "# division of the data into training set and test set\n", "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", "\n", "# training the linear regression model\n", "reg = LinearRegression().fit(X_train, y_train)\n", "\n", "# prevision on test set\n", "y_pred = reg.predict(X_test)\n", "\n", "# calculation of mse\n", "mse = mean_squared_error(y_test, y_pred)\n", "\n", "# calculation of bias and variance\n", "bias = np.mean((y_test - y_pred)**2)\n", "variance = np.var(y_pred)\n", "\n", "# graph of the linear regression\n", "plt.scatter(X_test, y_test, label=\"True value\")\n", "plt.plot(X_test, y_pred, label=\"Prediction\")\n", "plt.legend()\n", "plt.show()\n", "\n", "# result\n", "print(\"Bias:\", bias)\n", "print(\"Variance:\", variance)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 300 }, "id": "Tn_GKvZmduQV", "outputId": "874bafc9-9592-4265-8ad0-b141330735ff" }, "execution_count": 56, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAcsklEQVR4nO3df3RU5b3v8ffXECQIhl9BJQGDLVADYtAQtVzFFhTaY1FRTqGrVW79hb2e47WntLrOXYq2PXqK13qqLjH9pbU9C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RKoFekuwKpBCdi2N0Lo7RuThG56INKdGHLiIiJy9VWugiInKSFOgiIhERaqBrXvVjApyLb5tZuZltMLMVZnZ2MuoZhljnolm568zMzSyyQ9aCnAsz+8fG343NZvafYdcxLAH+RoaY2atmtq7x7+TLyahnSnH3UP7RcJfpO8A5QHfgv4GCFmW+BcxrfDwdmB9W/cL8F/BcfAHo2fj49q58LhrL9QZWAWuAomTXO4m/F8OAdUDfxucDk13vJJ6LEuD2xscFwPZk1zvZ/8JsoTfNq+7uh4Cj86o3dzXwTOPjhcAEM7MQ6xiWmOfC3V919wONT9fQMClaFAX5vQD4Pg0LpxwMs3IhC3IubgGecPe9AO7+Ych1DEuQc+HA6Y2Ps4GdIdYvJYUZ6HGbVz0CgpyL5m4CliW0RskT81yY2QXAYHdfEmbFkiDI78VwYLiZrTazNWY2ObTahSvIuZgDfN3MKoGlwD+FU7XUFWTFIkkiM/s6UASMT3ZdksHMTgEeAWYmuSqpohsN3S6X0/CtbZWZnefuNUmtVXLMAJ529/9rZpfQMEHgKHevT3bFkiXMFrrmVT8myLnAzCYC/wpMcfdPQ6pb2GKdi97AKGClmW0HLgYWR/TCaJDfi0pgsbsfdvdtwNs0BHzUBDkXNwELANz9L0APGibu6rLCDHTNq35MzHNhZmOAp2gI86j2k0KMc+Hu+9x9gLvnu3s+DdcTprh7WXKqm1BB/kYW0dA6x8wG0NAF826YlQxJkHPxPjABwMzOpSHQu/TalqEFemOf+NF51bcAC7xxXnUzm9JY7OdA/8Z51b8NtDmELZ0FPBdzgV7Af5nZejNr+cscCQHPRZcQ8FwsB6rNrBx4FZjt7pH7FhvwXPwLcIuZ/TfwHDAzog3AwHTrv4hIROhOURGRiFCgi4hEhAJdRCQiFOgiIhGhQBcRiQgFuohIRCjQRUQi4v8DTlg92Wz8JXwAAAAASUVORK5CYII=\n" }, "metadata": { "needs_background": "light" } }, { "output_type": "stream", "name": "stdout", "text": [ "Bias: 0.07132226716060397\n", "Variance: 0.0018924772855634625\n" ] } ] }, { "cell_type": "markdown", "source": [ "In this case we have the heigest bias, but we have a small variance, since the model predictions will all be very similar to each other (since they will all be very far from true values)" ], "metadata": { "id": "GpxLQkg2hExr" } } ] }