Skip to content

Instantly share code, notes, and snippets.

@marcodiiga
Last active May 28, 2016 18:29
Show Gist options
  • Save marcodiiga/2174e737235b766e2540d39535a1b714 to your computer and use it in GitHub Desktop.
Save marcodiiga/2174e737235b766e2540d39535a1b714 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Linear Regression\n",
"\n",
"Linear regression is a mathematical approach to modeling the unknown parameters of linear predictor functions from data estimates. Let's suppose we have a discrete [uniformly distributed](https://en.wikipedia.org/wiki/Uniform_distribution_(discrete) set of data (we'll apply an ongoing bias and a spreading factor to better model an event sampling)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEACAYAAACj0I2EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFGdJREFUeJzt3X2MXFd9xvHncRxHG8DuGtZ21YAXWhWnlJSEJq0EUiaJ\n3aagJqhICW6LCF0qoZQGFYnGUFVZ/qCN+aMIiUaixaAEkRBIlReqVnEse1SBVLzNm9MQGyS029DG\nu0sCpmlWxSW//jF3zaw9uztvd+69534/0sqz13N3fj67fubsueec64gQAKD6NhRdAABgOAh0AEgE\ngQ4AiSDQASARBDoAJIJAB4BEdBXotrfY/prtZ2w/bfs3bI/bPmj7hO2HbW/Ju1gAwOq67aF/RtI/\nRcTFkn5N0nFJ+yQdiog3Sjos6WP5lAgA6IbXW1hke7OkxyPiF886flzSlRExb3uHpGZE7MqvVADA\nWrrpob9e0g9sf9H2Y7b/zvaFkrZHxLwkRcRJSdvyLBQAsLZuAn2jpMsk/W1EXCbpf9Qabjm7a88e\nAgBQoI1dPOf7kp6NiH/LPv8HtQJ93vb2tiGXhU4n2yboAaAPEeFenr9uDz0bVnnW9i9nh66R9LSk\nhyTdlB17n6QH1/gapfq47bbbCq+hCj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9TW4tsqzXqKrKt3pzV8URWw19kxwtrqzVqKkVG\nSbpS0kP9thMLiwAgEey2CACJINABIBEEOgAkgkAHgEQQ6ACQCAIdABJBoANAIgh0AEjE/wP2MQ6S\nxynPXgAAAABJRU5ErkJggg==\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x404d550>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"# Generate N samples in range [0;1[ with a uniform distribution\n",
"def generateRandomData(numberOfSamples):\n",
" x = np.zeros(shape=numberOfSamples)\n",
" y = np.zeros(shape=numberOfSamples)\n",
"\n",
" for i in range(0, numberOfSamples):\n",
" x[i] = i\n",
" # Generates values along a line with a fixed degree of variance\n",
" y[i] = i + np.random.uniform(0, 1) * 20\n",
"\n",
" return x, y\n",
"\n",
"def plotScatterData(x, y):\n",
" plt.scatter(x, y)\n",
" plt.show()\n",
"\n",
"x, y = generateRandomData(35)\n",
"plotScatterData(x, y)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the case for a linear regression (linear polynomial) we're interested in determining the parameters $\\theta_1$ and $\\theta_2$ for the *hypothesis* $h_\\theta(x)$ defined as\n",
"\n",
"$$\n",
"h_\\theta(x) = \\theta_0 + \\theta_1x\n",
"$$\n",
"\n",
"If we define a generic $h_\\theta(x)$ by assigning, for instance, $\\theta_1 = 1$ and $\\theta_2 = 1$, we will have an error that can be estimated by using the **sum of the squared error** method\n",
"\n",
"$$\n",
"J(\\theta_1, \\theta_2)=\\sum^{m}_{i=1}{(h_\\theta(x^{(i)}) - y^{(i)})^2}\n",
"$$\n",
"\n",
"and therefore the optimization problem we need to solve is finding $min \\ J(\\theta_1, \\theta_2)$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Gradient Descent\n",
"A straightforward approach to solving the optimization problem explained in the previous paragraph is the gradient descent method. The idea is to compute $\\nabla J(\\theta_1, \\theta_2)$ and use it as a negative gradient to find the decreasing direction of the multi-variable function $J$.\n",
"\n",
"Therefore (we're adding a $\\frac{1}{2m}$ factor to simplify computation)\n",
"\n",
"$$\n",
"\\begin{align}\n",
"& \\frac{\\partial}{\\partial \\theta_1}J(\\theta_1, \\theta_2) = \\frac{1}{m} \\sum^{m}_{i=1}{(h_\\theta(x^{(i)}) - y^{(i)})} \\\\\n",
"& \\frac{\\partial}{\\partial \\theta_2}J(\\theta_1, \\theta_2) = \\frac{1}{m} \\sum^{m}_{i=1}{(h_\\theta(x^{(i)}) - y^{(i)}) x^{(i)}}\n",
"\\end{align}\n",
"$$\n",
"\n",
"If we choose a suitable $\\alpha$ factor (the *learning rate*) for the descent in the $-\\nabla$ direction (a compromise between convergence speed and actually converging to a function minimum), the algorithm becomes\n",
"\n",
" while(!converged) {\n",
" theta1 = theta1 - alpha * nabla[0];\n",
" theta2 = theta2 - alpha * nabla[1];\n",
" // Verify convergence\n",
" }"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEACAYAAACj0I2EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHepJREFUeJzt3XmUVeWV9/HvRoaUUbDAEkzUKo1G1Dgm4pvWxEIlTnGM\ngaB2mohGgwhJZxmIybvE1avTkqkXOMSJGNGAoAKaaEchcmNrWikZxCCgrULQV4oKCIoiQ9V+/3gu\nUpQ13Pmce+7vs1Ytbh3uuWdzqtj3ufs8zz7m7oiISPnrFnUAIiJSGEroIiIJoYQuIpIQSugiIgmh\nhC4ikhBK6CIiCZFRQjezPmb2kJktN7NlZnaSmVWb2VNmttLMnjSzPsUOVkREOpbpCH0S8IS7HwEc\nC6wAxgPz3P1w4Gngx8UJUUREMmFdLSwys97AYnf/XJvtK4BT3b3RzAYAKXcfWLxQRUSkM5mM0A8G\n/mFm95rZIjO7y8z2BPq7eyOAu68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ixdmFkVMIRQ24/sXHUQ04ooz5O73+DuB7n7IYSc9LS7/zPhTWVE+mmZnSd3L/oXMBVYCiwB5hBq\nQyU5djuxnEVY4foaMD6qOFrFc3D6vCwGXo4qJmAaYebPVuDvhFkb1cC89Pl6CtgnJnFF9vtEGE01\nt/qZLUr/TvWN8lx1EleU5+rodBxL0jH8JL09snPVSUyxyFHAqcBjuZ4nLSwSEUkIdVsUEUkIJXQR\nkYRQQhcRSQgldBGRhFBCFxFJCCV0EZGEUEIXEUkIJXQRkYT4/+ue6NETmxy8AAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x70622b0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"def gradientDescent(x, y, alphaFactor, numIterations):\n",
" theta = np.ones(2)\n",
" x_transposed = x.transpose()\n",
" n_samples, = np.shape(x)\n",
"\n",
" np.seterr(all='raise') # Watch out for overflows\n",
"\n",
" for i in range(0, numIterations):\n",
"\n",
" hypothesis = np.zeros(n_samples)\n",
" for sample in range(0, n_samples):\n",
" hypothesis[sample] = theta[0] + theta[1] * x[sample]\n",
"\n",
" error_vector = hypothesis - y\n",
"\n",
" gradient = np.zeros(2)\n",
" gradient[0] = np.sum(error_vector) / n_samples\n",
" gradient[1] = np.dot(x_transposed, error_vector) / n_samples\n",
"\n",
" theta = theta - alphaFactor * gradient\n",
" \n",
" return theta\n",
"\n",
"def plotLinearPredictor(x, y, theta_coefficients):\n",
" plt.scatter(x, y)\n",
" \n",
" y_regression = np.zeros(len(x))\n",
" for sample in range(0, len(x)):\n",
" y_regression[sample] = theta_coefficients[0] + theta_coefficients[1] * x[sample]\n",
"\n",
" plt.plot(x, y_regression)\n",
" plt.show()\n",
" \n",
"theta_coefficients = gradientDescent(x, y, 0.001, 100000)\n",
"\n",
"plotLinearPredictor(x, y, theta_coefficients)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Multivariate gradient descent\n",
"\n",
"The generalized version for multiple features is\n",
"\n",
"$$\n",
"\\forall \\ j \\quad \\theta_j = \\theta_j - \\alpha \\frac{\\partial}{\\partial \\theta_j}J(\\theta_1, \\theta_2, \\cdots, \\theta_n) = \\frac{1}{m} \\sum^{m}_{i=1}{(h_\\theta(x^{(i)} - y^{(i)})^2} x^{(i)}_j\n",
"$$\n",
"\n",
"where $x^{(i)}_j$ is the $j$-th feature $i$-th sample."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Normal equation method\n",
"\n",
"An analytical solution exists and as it is the common case in calculus it involves \n",
"\n",
"$$\n",
"\\theta \\in \\mathbb R^{n+1} \\quad \\forall \\ j \\quad \\frac{\\partial}{\\partial \\theta_j}J(\\theta) = 0\n",
"$$\n",
"\n",
"although this is straightforward, there's a simpler method to calculate the system solution vector. Let us define a *design matrix* and a $y$ vector for the training data\n",
"\n",
"$$\n",
" X = \n",
" \\begin{bmatrix}\n",
" X^{(1)}_0 & X^{(1)}_1 & \\cdots & X^{(1)}_n \\\\\n",
" X^{(2)}_0 & X^{(2)}_1 & \\cdots & X^{(2)}_n \\\\\n",
" \\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
" X^{(m)}_0 & X^{(m)}_1 & \\cdots & X^{(m)}_n \\\\\n",
" \\end{bmatrix}\n",
" \\qquad\n",
" y =\n",
" \\begin{bmatrix}\n",
" y^{(1)} \\\\\n",
" y^{(2)} \\\\\n",
" \\vdots \\\\\n",
" y^{(m)} \\\\\n",
" \\end{bmatrix}\n",
"$$\n",
"\n",
"It turns out that\n",
"\n",
"$$\n",
"\\theta = (X^TX)^{-1} X^Ty\n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEACAYAAACj0I2EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHeZJREFUeJzt3XmUVeWV9/HvRoaUUbDAEkw0VRqNqHFMxE5rYqES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pnZkUR8rtqJ6Qgi\nPE9mdg7QmP6E1dmnhC7PU87TFj9xJPchGT71HuB3hTpult4BPtfq+wPS2yLl7u+m/2wys1mE0tBz\n0UYFQKOZ9Xf3xnSNdl3UAUE4T62+Lfnvk5l1JyTNB9z98fTmyM9Ve3FFfa52cvf3zSwFnEkMzlXb\nmNrUzkt9nk4CzjOzs4EqYG8zewBYm+15KtUslwGtvr0I+EspjtuOBuAQM6s1s57At4EnIooFCBdo\n0qMqzOzTwNeJ7vwYu48QngBGpB//K/B42x1KZLe4YvD79GvgVXef1GpbHM7VJ+KK8lyZ2b47Sxdm\nVgUMIdT2IztXHcS0Isrz5O7Xu/vn3P1gQk56xt3/hfCmMiL9tMzOk7sX/QuYCiwFlgCzCbWhkhy7\nnVjOJKxwfR0YH1UcreI5KH1eFgOvRBUT8DBh5s9W4K+EWRvVwLz0+ZoD7BOTuCL7fSKMpppb/cwW\npX+n+kZ5rjqJK8pzdVQ6jiXpGG5Ib4/sXHUSUyxyFHAK8ESu50kLi0REEkLdFkVEEkIJXUQkIZTQ\nRUQSQgldRCQhlNBFRBJCCV1EJCGU0EVEEkIJXUQkIf4/XCvo11jAMkYAAAAASUVORK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x7085f60>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"def normEquation(x, y):\n",
" ll = []\n",
" for sample in x:\n",
" ll += [[1] + [sample]]\n",
" X = np.matrix(ll)\n",
" ll = [[sample] for sample in y]\n",
" y = np.matrix(ll)\n",
" x_trans = X.T\n",
" A = (x_trans * X).I\n",
" theta = A * x_trans * y\n",
" return theta\n",
"\n",
"theta_coefficients = normEquation(x, y)\n",
"plotLinearPredictor(x, y, theta_coefficients)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Considerations\n",
"\n",
"The normal equation method doesn't require an iterative approach and doesn't need features adjustments like *feature scaling*, *mean normalization* or *learning rate adjustment* either. Downside is that the normal equation method doesn't scale well with a huge number of features (big matrix inversion ~ doesn't scale up well)."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment