Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lazy-programmer-courses
/
linear-regression
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f42cc00d
authored
Jul 30, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
class 10 is done
parent
93ead254
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
241 additions
and
4 deletions
linear_regression_1d.ipynb → 1_linear_regression_1d.ipynb
2_r_squared.ipynb
linear_regression_1d.ipynb
→
1_
linear_regression_1d.ipynb
View file @
f42cc00d
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
10
,
"execution_count":
5
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -71,7 +71,7 @@
...
@@ -71,7 +71,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
23
,
"execution_count":
6
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -97,7 +97,7 @@
...
@@ -97,7 +97,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
25
,
"execution_count":
7
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -107,7 +107,7 @@
...
@@ -107,7 +107,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
2
8,
"execution_count": 8,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
...
2_r_squared.ipynb
0 → 100644
View file @
f42cc00d
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"X = []\n",
"Y = []"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"for line in open('../csv_files/data_1d.csv'):\n",
" x, y = line.split(',')\n",
" X.append(float(x))\n",
" Y.append(float(y))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"X = np.array(X)\n",
"Y = np.array(Y)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3X181OWZ7/HPlQchRATyICAJIDbaTT0tbTn7Kuv60KKtuK5Fd7sqUdGqLCgeikofXU6Oi+fsCohUKiy1VtTA1m2htRyxVbZVt7XdjV0Pa6NtFI1EEfIAiBBjHq7zx/wSJ2EmmWRmksnM9/165ZXMb34z+Y2D19y57uu+bnN3REQkfWUN9wWIiEhyKdCLiKQ5BXoRkTSnQC8ikuYU6EVE0pwCvYhImlOgFxFJcwr0IiJpToFeRCTN5Qz3BQAUFRX59OnTh/syRERGlBdeeKHR3Yv7Oy8lAv306dOprq4e7ssQERlRzKwulvOUuhERSXMK9CIiaa7fQG9mpWb2CzN72cx+b2ZLg+MFZvaUmdUG3ycEx83Mvm1mr5rZbjP7VLJfhIiIRBfLiL4duM3d/wT4DHCzmZUDXwd2uXsZsCu4DTAXKAu+FgIbEn7VIiISs34Dvbvvc/ffBT8fAV4GpgBfBDYHp20G5gU/fxF42EN+A4w3s8kJv3IREYnJgHL0ZjYd+CTwW2Ciu++D0IcBcHJw2hRgb9jD6oNjvZ9roZlVm1l1Q0PDwK9cRCRFVFVt4dS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YZ0v3X2fu/8u+PkIof/ZpxB6zZuD0zYD84bnCpPHzEqAvwAeCG4b8Dngh8Epafm6AczsJOAc4HsA7v6Bux8iA953Qvtg5JlZDjAG2Ecav+/u/izQ3OtwtPf5i8DDHvIbYLyZTY73GlIx0Gds50szmw58EvgtMNHd90HowwA4efiuLGnuBb4KdAa3C4FD7t4e3E7n934G0AB8P0hdPWBm+aT5++7ubwGrgTcJBfjDwAtkzvveJdr7nJT4l4qBvt/Ol+nIzE4EfgR8xd3fHe7rSTYzuxg44O4vhB+OcGq6vvc5wKeADe7+SeAoaZamiSTIRX8ROBU4BcgnlK7oLV3f9/4k5f+BVAz0/Xa+TDdmlksoyFe5+7bg8P6uP9mC7weG6/qS5CzgEjN7g1B67nOERvjjgz/pIb3f+3qg3t1/G9z+IaHAn+7v+/nA6+7e4O5twDbgz8ic971LtPc5KfEvFQN9RnW+DPLS3wNedvd7wu56HFgQ/LwA+MlQX1syufs33L3E3acTeo//1d0rgF8Afx2clnavu4u7vwPsNbMzgkNzgBrS/H0nlLL5jJmNCf7td73ujHjfw0R7nx8Hrgmqbz4DHO5K8cTF3VPuC7iI0J6zrwHfGu7rSfJr/XNCf5rtBl4Mvi4ilK/eBdQG3wuG+1qT+N/gPGBH8PMM4N+BV4F/AUYN9/Ul8XXPBKqD9/7HwIRMeN+B/wW8ArwEPAKMSuf3HdhKaD6ijdCI/fpo7zOh1M13gtj3X4Sqk+K+Bq2MFRFJc6mYuhERkQRSoBcRSXMK9CIiaU6BXkQkzSnQi4ikOQV6EZE0p0AvIpLmFOhFRNLc/wegbpAeAsTEcQAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.scatter(X, Y, edgecolors='k')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"denominator = X.dot(X) - X.mean()*X.sum()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.9726121674845993"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = ( X.dot(Y) - Y.mean() * X.sum() ) / denominator\n",
"a"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2.8644240756601382"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b = ( X.dot(X) * Y.mean() - X.dot(Y) * X.mean() ) / denominator\n",
"b"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"Yhat = a*X + b"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xt81OWZ9/HPlYMkQU4hgQAJCUjETV2kNWuLPlWfYluxVtF2BYlKu22pB1pFQawPZfNQyq5FBCoVl1ZbLEFtV2Utj/Ygu6u7rT3ErstaRINgJIqQAIJCiCS5nj9mEmYyM8lAMjlMvu/XK69k7vn9frnHkSv3XL/7vm5zd0REJHml9HQHREQksRToRUSSnAK9iEiSU6AXEUlyCvQiIklOgV5EJMkp0IuIJDkFehGRJKdALyKS5NJ6ugMAOTk5XlRU1NPdEBHpU1566aU6d8/t6LheEeiLioqorKzs6W6IiPQpZlYdz3FK3YiIJDkFehGRJKdALyKS5BToRUSSnAK9iEiS6zDQm1mBmf2bmb1qZn8xs1uD7dlm9hszqwp+HxZsNzP7vpntMLOtZvaxRL8IERGJLZ4RfSNwh7v/FfAJ4BYzKwHuAra4ezGwJfgYYBpQHPy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VvnT3Pe7+5+DP7xP4xz6GwGteHzxsPTC9Z3qYOGaWD3wO+FHwsQGfAv45eEhSvm4AMxsMXAg8BODuH7r7e/SD953APhiZZpYGZAF7SOL33d1fAA60aY71Pl8JPOIBvweGmtmozvahNwb6DitfJiszKwI+CvwBGOnueyDwxwAY0XM9S5hVwJ1Ac/DxcOA9d28MPk7m9348UAv8OJi6+pGZDSTJ33d3fxu4F3iLQIA/BLxE/3nfW8R6nxMS/3pjoO+w8mUyMrPTgSeA29z9cE/3J9HM7HJgn7u/FNoc5dBkfe/TgI8Ba939o8ARkixNE00wF30lMA4YDQwkkK5oK1nf944k5N9Abwz0/a7ypZmlEwjyFe7+ZLB5b8tHtuD3fT3VvwS5ALjCzN4kkJ77FIER/tDgR3pI7ve+Bqhx9z8EH/8zgcCf7O/7JcAud6919+PAk8D59J/3vUWs9zkh8a83Bvp+VfkymJd+CHjV3e8LeeppYHbw59nAv3R33xLJ3b/l7vnuXkTgPf5Xdy8D/g34YvCwpHvdLdz9XWC3mU0MNk0FtpHk7zuBlM0nzCwr+P9+y+vuF+97iFjv89PADcHZN58ADrWkeDrF3XvdF3AZgT1n3wD+T0/3J8Gv9X8R+Gi2FXg5+HUZgXz1FqAq+D27p/uawP8GFwObgz+PB/4I7AB+Dgzo6f4l8HVPBiqD7/0mYFh/eN+B/wtsB14BfgoMSOb3HXiUwP2I4wRG7F+J9T4TSN38IBj7/ofA7KRO90ErY0VEklxvTN2IiEgXUqAXEUlyCvQiIklOgV5EJMkp0IuIJDkFehGRJKdALyKS5BToRUSS3P8HQRgB165xVM0AAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.scatter(X, Y, edgecolors='k')\n",
"plt.plot(X, Yhat, color='red')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2479.6099146071415"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# calculate difference between Y actual and Y hat\n",
"d1 = Y - Yhat\n",
"# calculate sum of squared residuals\n",
"ssr = d1.dot(d1)\n",
"ssr"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"281256.7345902547"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# calculate difference between Y actual and Y mean\n",
"d2 = Y - Y.mean()\n",
"# calculate total sum of squares\n",
"sst = d2.dot(d2)\n",
"sst"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"R-squared is equal 0.9911838202977805\n"
]
}
],
"source": [
"# calculate r2\n",
"r2 = 1 - ssr / sst\n",
"print('R-squared is equal', r2)"
]
}
],
"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.5.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment