{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "preamble": true
   },
   "source": [
    "(Defining latex commands: not to be shown...)\n",
    "$$\n",
    "\\newcommand{\\norm}[1]{\\left \\| #1 \\right \\|}\n",
    "\\DeclareMathOperator{\\minimize}{minimize}\n",
    "\\newcommand{\\real}{\\mathbb{R}}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  Monster vs. Mouse (50 Points)\n",
    "\n",
    "While trying to sleep, you hear some noise under your bed. Being a big Science Fiction fan you obviously immediately think it's a monster. A BIG monster... or maybe two?!? Frightened to death, you do not dare to move, but your brain is racing. And it recalls that the other day, you saw a mouse disappearing on the other side of the bedroom... So maybe it is (just?!?) a mouse. Or, just something else... Hmmm. Remembering your Emperical Inference classes, you decide to evaluate the probability that, given some noise under your bed, there is a monster.\n",
    "\n",
    "You define the random variables:\n",
    "\n",
    " + n = some noise under your bed (Values 0 or 1)\n",
    " + M = 0, 1 or 2 monsters under your bed (Values 0, 1 or 2)\n",
    " + m = a mouse under your bed (Values 0 or 1)\n",
    " + e = something else (e.g. only air) under your bed (Values 0 or 1),\n",
    "\n",
    "and express your beliefs about monsters, mice and noise, by assigning numbers to P(M), P(m), P(e), P(n|M), P(n|m), P(n|e). Given that you heard some noise under your bed, you then calculate the Maximum a Posteriori (MAP) of M (i.e., the maximum of P(M|n=1)).\n",
    "\n",
    "Please share your beliefs and your results with us."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Programming a Hand-Featured SVM  (50 points)\n",
    "\n",
    "The goal of this exercise is to implement a very simple SVM using an off-the-shelf optimizer, in the case of a 2-dimensional input space.\n",
    "Most of it has already been implented in an iPython Notebook that you can find on the homepage of the course, and that we reproduce hereafter.\n",
    "\n",
    "You are asked to hand out a print out of the lines marked \"### CHANGE THIS LINE ###\", as well as your plots."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The SVM equation in the linear separable case\n",
    "\n",
    "Let $(x_1,t_1), \\ldots, (x_N,t_N) \\in \\real^p \\times \\{-1,1\\}$ be N data points with their binary labels. For this exercise, $p=2$.  \n",
    "In the lecture, we saw that trying to maximize the margin between two linearly separable classes of data points led to the problem:\n",
    "\\begin{equation}\n",
    "    \\minimize_{\\substack{ \\{ w \\ \\in \\real^2,\\ b \\ \\in \\ \\real \\} }} \\frac{1}{2} \\norm{w}^2 \\quad \\mathrm{subject \\ to} \\quad t_n(w^T x_n + b) \\geq 1 \\quad n = 1 \\ldots N ,\n",
    "\\end{equation}\n",
    "whereby the points are subsequently classified according to the rule:\n",
    "\\begin{equation}\n",
    "    t = \\left \\{ \n",
    "        \\begin{array}{cc}\n",
    "             \\ \\ 1 \\quad \\mathrm{if} \\quad w^T x + b \\geq 0 \\\\\n",
    "             -1 \\quad \\mathrm{if} \\quad w^T x + b < 0\n",
    "        \\end{array}\n",
    "        \\right . .\n",
    "\\end{equation}\n",
    "The function $\\mathop{l}(w,b) :=  \\frac{1}{2} \\norm{w}^2$ is called the _objective_ function. The equations $t_n(w^T x_n + b) \\geq 1$ are called the (_inequality_) _constraints_.\n",
    "\n",
    "In practice, one often preferres to transform this problem into its so-called _dual_ formulation. However, in this exercise, we will stick to the above equations: the _primal_ formulation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Loading the required packages."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import numpy as np\n",
    "from numpy import *\n",
    "from scipy import optimize\n",
    "from matplotlib import pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Definition of the data point  \n",
    "\n",
    "_X = location of the data points_ $\\in \\real^{N \\times 2}$  \n",
    "_t = label class of each point_ $\\in \\real^N$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "X_ = np.array([[1.,3.],[2.,6.],[2.,3.],[-1.,0],\n",
    "             [1.,0.],[2.,2.],[3.,1.],[0.,-1.]])\n",
    "t_ = np.array([1,1,1,1,-1,-1,-1,-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Definition of the Objective Function and its Gradient\n",
    "\n",
    "_wb = $(w_1, w_2, b) = (w , b)$_ $\\in \\real^2 \\times \\real$\n",
    "\n",
    "(Note that the gradient of the objective function (here called 'jac') does not appear in the equations of an SVM. But our off-the-shelf optimizer uses it for its computations.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def objective(wb):\n",
    "    ### changed ###\n",
    "    return 0.5*(wb[0]**2+wb[1]**2)\n",
    "def jac(wb):\n",
    "    return hstack((wb[0:2],array([0])))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Definition of the Inequality Constraints and of their Gradient\n",
    "\n",
    "(Again, the gradient does not appear in the SVM equations, but it is needed for our optimizer.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def ineq(wb):\n",
    "    #writing \"return a-b\" would encode the constraint a-b >= 0\n",
    "    ### changed ###\n",
    "    return t*(np.dot(wb[0:2],X.T)+wb[2])-1\n",
    "\n",
    "def grad(wb):\n",
    "    return -1*hstack(((-t*X.T).T, -t[:,newaxis]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Optimisation of the SVM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-2.  2. -1.]\n"
     ]
    }
   ],
   "source": [
    "def optimizeSVM(X_,t_):\n",
    "    global X,t\n",
    "    X = X_\n",
    "    t = t_\n",
    "    wb0 = np.random.randn(3) #initialization\n",
    "    #wb0 = array([-1.,-2.,0.2])\n",
    "\n",
    "    cons = {'type':'ineq', #constraints\n",
    "            'fun': ineq,\n",
    "            'jac': grad}\n",
    "\n",
    "    opt = {'disp':False}\n",
    "\n",
    "    opt_result = optimize.minimize(objective, wb0, jac=jac,constraints=cons, #the optimizer\n",
    "                                     method='SLSQP', options=opt)\n",
    "    wb_opt = opt_result[\"x\"] #result of the optimization\n",
    "    \n",
    "    return wb_opt\n",
    "\n",
    "wb_opt = optimizeSVM(X_,t_) #the optimized parameters\n",
    "print(wb_opt)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plotting the Result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": [
       "iVBORw0KGgoAAAANSUhEUgAAAXAAAAEACAYAAACqOy3+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n",
       "AAALEgAACxIB0t1+/AAAIABJREFUeJzt3XuYXFWd7vHvSwK5kKBwVEYkiANqAsEQjgQiAo1XaB0d\n",
       "RlG8zIghmTkDpAMiwjgjncILCAqSgBwNgiJ4GW6O3JQg9hkQDiA3RcBLPJjg4SaOmGiiQX7zx6rQ\n",
       "3aE76e61q2rvqvfzPDxQ1VVr/4wPv16svfa7FBGYmVn1bNHqAszMbGzcwM3MKsoN3MysotzAzcwq\n",
       "yg3czKyi3MDNzCoqq4FLeqWkuwf89ZSknqKKMzOz4amofeCStgB+DcyJiFWFDGpmZsMqcgnlDcAK\n",
       "N28zs+YosoEfDnytwPHMzGwTCllCkbQVaflkt4h4IntAMzPbrPEFjXMIcOdQzVuSw1bMzMYgIrSp\n",
       "nxfVwN8DfH2sRZSBpMURsbjVdWxOFeqsQo3gOovmOos1kslv9hq4pK1JNzCvyB3LzMxGLnsGHhF/\n",
       "AF5QQC1mZjYKfhKzX1+rCxihvlYXMAJ9rS5ghPpaXcAI9bW6gBHqa3UBI9TX6gKKUtiDPMNeQIoq\n",
       "rIGbmZXJSHqnZ+BmZhXlBm5mVlFu4GZmFeUGbmZWUW7gZmYV5QZuZlZRbuBmZhXlBm5mVlFu4GZm\n",
       "FeUGbmZWUW7gZmYV5QZuZlZRbuBmZhXlBm5mVlFFnMjzfEmXSXpA0v2S9i2iMDMz27QizsQ8G7g2\n",
       "It4paTywdQFjmjXMTKl7GvRMhYmrYd0qWHJfxLWtrststLIauKTnAftHxAcAIuJp4KkiCjNrhJlS\n",
       "91w4exnsuuG9BbDLTAk3caua3CWUlwFPSLpQ0l2SlkmaXERhZo0wDXoGNm+AZbDrTrCwVTVZE0nP\n",
       "R5rU6jKKkruEMh7YCzgmIu6Q9DngJODkgR+StHjAy76I6Mu8rtmYTIWJQ70/BdrmX2obgrQFcATw\n",
       "KWA+cHVL6xmCpC6gazTfyW3gDwMPR8Qd9deXkRr4IBGxOPM6ZoVYDeuGen8NrG12LdYk0t7AOcAz\n",
       "wFuIuLPFFQ2pPrHt2/BaUu/mvpO1hBIRjwKrJL2i/tYbgJ/kjGnWSKtgyQL4xcD35sOKlbC0VTVZ\n",
       "g0gvRFoGfBs4D9ivrM17rLJPpZc0Czgf2ApYAXwwIp4a8HOfSm+lMlPq3gkWToFJa2DtSljqG5ht\n",
       "JO2G+19AL3AxsJgBPakqRtI7sxt4EUWYmRVC2p+0XPIk0EPEfS2uaMxG0juL2AduZtZa0g7AGcD+\n",
       "wIeBS2n07LQE/Ci9mVWXtBXSCcCPgIeAGUT8eyc0b/AM3MyqSnoTsIR0721fIn6xmW+0HTdwM6sW\n",
       "aWfgTGAWsIiI0u3pbhYvoZhZNUiTkE4GfgjcBezeyc0bPAM3s7KTBLwNOAu4E9iLiJWtLaoc3MDN\n",
       "rLzSQ4JnAy8FFhDxvRZXVCpeQjGz8pGmIJ0G3AIsB2blNm+J7STOkXhdITWWgBu4mZWHJKTDgQeA\n",
       "FwN7EHEmEevHPiTjJBbUxxwH3FtMsa3nJRQzKwdpD1ImzfOAw4n4Qf6Q7EN6MnM9cEgEd+WOWSae\n",
       "gZtZa6WM7rOB7wHfBF6d27wlXiTxJeBK0i+F17Zb8wY3cDNrFWkLpHnAg8AEYDciziPiL2MfkvES\n",
       "PaRU1N8BMyK4KIJniim6XLyEYmbN14CMbokDSbPtJ4CuiPaPtnYDN7PmkV5IOhXnraTDX75KRNbs\n",
       "WGJHUpDVfsCHgMsj6IgsFC+hmFnjSeORjiYtbawGphPxlZzmLTFB4kTSrpIVpOWSyzqleYNn4GbW\n",
       "aIMzug8iIntpQ+Jg0gM+PwP2iaDjgqyggAYu6SHg98BfgPURMSd3TDNrAymj+3TgAArK6JZ4GemR\n",
       "+pnAsRHlO5y4mYpYQgmgKyJmu3mb2UYZ3b+igIxuickSNVKQ1e3AzE5v3lDcEoqPTDOzwjO6JQT8\n",
       "LWnWfTswOwIHWdUV0cADuEHSX4AvRMSyAsY0sypJGd2fBfakoIxuiemkXwYvAeZFcGP2mDXtCfz/\n",
       "6I3Hc8cqgyIa+H4R8YjS9qDlkh6MiJsGfkDS4gEv+yKir4DrmlmrSZOAE4Ae4HPA+4hYlzckU4GP\n",
       "AfOATwLnRDDmLBQA1bQd8HHgncC7gNI1cEldQNeovlPk0XGSeoE1EfHZAe/5VHqzdvPcjO7jczO6\n",
       "68sl7wU+DdwAnBTBo1lj1jQOOJLUvC8FTo7e+G3OmM3S8FPpJU0GxkXEaklbA28CajljmlnJNSCj\n",
       "W2IW6SnKKcC7Irgle8ya9iVtX1wHvDl6457cMcsmdwlle+DK9MuY8cAlEXF9dlVmVj7SFODfgPmk\n",
       "pymX5sS8piHZljQ7Pgw4GTg/gjFnoQCopu2B00gTyhOBS6K3PU+pz2rgEfH/SDctzKxdpRnau0mP\n",
       "q99Iyuh+JG9ItiCtcX+ClBi4WwRPZo1Z05bAUaRfMl8GZkRv/D5nzLLzk5hmNrzGZHTPIS1tPA10\n",
       "FxHzqpoOItX5CHBA9MYDuWNWgRu4mT2X9HzS/az3AL3AF3NiXtOQvAg4FTiEFGR1cW7Mq2raEfgM\n",
       "sC8pyOrKdl0uGYobuJn1k7YAjiCtcX+LlNH9m7whGU9a2vgYcBEpdOqprDFrmkBq2McD5wLzojf+\n",
       "mDNmFbmBm1lSkYxu1dRN2gVzPzAneuOXuWNWlRu4WaerSEa3avpr0sNC04Ge6I3rcsZrB84DN+tU\n",
       "FcnoVk2TVdMppCyUW4A93LwTz8DNOlEFMrpVk4BDgTOBW4E9ozcezq2znbiBm3WSimR0q6YZpCCr\n",
       "vwKOiF7nJw3FSyhmnaDxGd13UEBGt2raRjWdAfwncBUw2817eJ6Bm7W7CmR015dL3kcKsvouMDN6\n",
       "47GcMTuBG7hZu0oZ3WcCsyh/RvdSYBLwjuiN/5s7ZqfwEopZu5EmIZ1MWtq4C9g9t3lLTJU4HbgZ\n",
       "uA7YM7d5q6btVNO5pBn3RcA+bt6j4xm4Wbt4bkb3Xg3I6J5ZUEb3hiCrS0mhU5XI6C4bN3CzduCM\n",
       "7o7kJRSzKpOmIJ1GesBlOTArt3lLbCtxDnA9cAmwd27zVk3bq6YLgMtJT1Pu7+adzzNwsyqqTkb3\n",
       "eOBoOiiju5kKaeCSxpFumDwcEX9TxJhmNozqZHR3kep8lA7K6G6mombgi0jJYFMLGs/MNuaMbttI\n",
       "9hq4pB2BbuB8wKfPmxVN2gJpHvAgMIGU0X1eTvOWGC/RQwqy+h0pdOqinOatmiaoppOAe4CfArtF\n",
       "b1zh5t04RczAzwJOALYpYCwzG0h6NenAgrJndB9C2gXzAB2e0d1MWQ1c0luBxyPibkldm/jc4gEv\n",
       "+yKcbWC2SYMzuv8FuKjEGd1nAbsBi6I3rs0Zr5PVe2jXqL6TE0Qm6VPA35NufEwkzcIvj4h/GPCZ\n",
       "iAgvrZiNhDQe+CfSGvfFQI2IvOPHxATgWOAjwHnAqRH8IWvMmiaT1syPIq13nxW98aecMW2wkfTO\n",
       "rAa+0cUOBD688S4UN3CzERqc0b2wARndxzUgo/sEZ3Q3xkh6Z9H7wH2zwmy0nNFtY1TYk5gR8X8i\n",
       "4m1FjWfW9hqf0X07zuhua34S06wVnNFtBXADN2smZ3RbgRxmZdYMzui2BvAM3KyRnNFtDeQGbtYo\n",
       "zui2BvMSilnRnNFtTeIZuFlRBmd0fx9ndFuDuYGbFcEZ3dYCbuBmOZzRbS3kBm42FtIWwBGkxMD/\n",
       "IGV0/yZvSMaTwqE+RtrCNyOCvCCrmiYAx5Ee0T8XmBe98cecMa083MDNRkvam7S04Yxuayk3cLOR\n",
       "ql5G9wxSRvd1OeNZeXkbodnmSOORjiYdP7YGmE7El3Oat8QEiROBe0l5KDMiuCyneaumyarpFFIW\n",
       "yq3AHm7e7c0zcLNNGZzR/Toi7ssfclBG9z4NyOje0xndncEN3Gwo/RndBwLH44xuK6GsJRRJEyXd\n",
       "JukeSfdLOrWowsxaYnBG90qc0W0lljUDj4h1kg6KiD8qneV3s6TXRsTNBdVn1jz9Gd2/BOYS8fO8\n",
       "4ZzRbY2VvYQS8eye0q2AcYATzDrUTKl7GvRMhYmrYd0qWHJflO+U8o3rnAHfODMlBs4iHf57dQHL\n",
       "Jc7otobLbuBKDzTcBewCnBcR92dXZZUzU+qeC2cvg103vLcAdpkpUaYmPlSdf4Q33gWX7JUyutfl\n",
       "jC8xlfQgzjzgk8A5EazPGrOm7YCPA+8k5ZdcEL15T3tae8jeRhgRz0TEnsCOwAGSurKrssqZBj0D\n",
       "myLAMth1J1jYqpqGMlSdk2GLf4MX5jRvCUm8j/TQzItI69xn5TRv1TRONS2ojxmk0Kllbt62QWG7\n",
       "UCLiKUnXAK8G+gb+TNLiAS/7Inyzpd1MhYlDvT8l/ed+aewB2w71fk6dzui2ItQnv12j+U5WA5f0\n",
       "AuDpiPidpEnAG0nBPoNExOKc61j5rU6N5jnWwNpm1zIkaQrwb70we6gfj6VOiW1JSxuHAScD50eQ\n",
       "F2RV0/akIKs3AycClzh0qjPUJ7Z9G15L6t3cd3KXUF4M3CjpHuA24Koo4NQRq55VsGQBgx9ImQ8r\n",
       "VqaZaetIQjqctAyxw7Hwwdw6JbaQmF8fcxwpo/sLOc1bNY1XTYuA+0gPDc2I3rjYzds2RZk32zd/\n",
       "ASkiQg29iJXCTKl7J1g4BSatgbUrYWlLb2AOzug+ZkNGd06dAzK61wMLG5DR3eOMboOR9U43cGs/\n",
       "jc/oPpGU0Z0bOuWMbhvWSHqnH6W39tGcjO7pEWQdP1bP6P4Q6RF9Z3TbmLmBW3tobEb348CBEWQ/\n",
       "46CauklBVvfjjG7L5AZu1dbYjO7XkGbJRWR070J6pH46aZ3bMa+WzXngVk2Nzei+h7RTZbcCM7pv\n",
       "A27BGd1WIM/ArXoan9G9b0EZ3X9Hyui+BWd0WwO4gVt1pIzuM4ADaExG96IIrskuc3BG9wcc82qN\n",
       "4iUUK7/BGd2/opiM7kkSi4E76M/ozmre9Yzuz5Ayuq8G9nLztkbyDNzKrTkZ3auyxnRGt7WIG7iV\n",
       "k7Qzaf24Chnd55DCvJzRbU3lJRQrF2kSKcTnTlLO/O5EXJW5XDJV4nTgJuBaYM/c5q2atlNN55Jm\n",
       "3BcB+7h5W7N5Bm7lIIl0Ks7nSM17LyJ+lTckAt5LWtq4AdgjgkezxqxpHHAkKYXwMlLolE+hspZw\n",
       "A7fWk15J2sL3UmABETfkD/lsRvfWwGER3Jo9pjO6rWS8hGKtI01BOg34AbAcmJXbvCW2lTgHuB64\n",
       "BJiT27xV0/aq6ULgCtJ/Iezv5m1l4Bm4NV9aLjmctKf7RmAPIh7JG5ItSOdQfoLUaHeL4MmsMWva\n",
       "EjiadA7ll4Hp0RtZQVZmRXIDt+aSXkVa2tgGePeGjO68IQdldHcXlNF9EKnOR0gzbmd0W+nkHqk2\n",
       "jXQH/kWkQ1e/GBFLiijM2kzK6D6FNPMuc0b3NAZndF/hjG4rq9wZ+HrguIi4R+nMwTslLY/wbMXq\n",
       "qpXRfTz9Gd0fdEa3lV1WA4+IR0nHQBERayQ9AOxAOivQOl1JM7qlmd0wrQemToTV6+i+7Rbm8Pek\n",
       "jO69ndFtVVHYGrjSk3OzSbGZ1slKnNGdmvfcs2HZrmy7Ag4+Dl60/nXcvu0n4prfnpJTo1mzFbKN\n",
       "sL58chmwKCLWFDGmVVDK6D6GUmd0T+thy7N35aCPwYI5sGounPObLbl237ljrdGsVbJn4JK2BC4H\n",
       "Lo6Ibw3zmcUDXvZFOKGt7fRndP+WMmd07/U/p3HADHh4Lvzve+D30+o/nTIpt16zHJK6gK5RfScn\n",
       "H0hpP+9XgCcj4rhhPuNT6dtZdTK6dwOW8F+T9uE/rpnCQwdt9Inu70Rce0judcyKMpLembuEsh/w\n",
       "fuAgSXfX/zo4c0yrgmpmdF/FF176Xh762kYz+fkrYOXSnOuYtULuLpSb8eP4nadxGd1nUmxG9/tJ\n",
       "QVbfAXaP3niMXpBm/gW6F6ZlkzVrYeXSiPuuzbmeWStkLaGM6AJeQmkfjcnofiXpl8GOwMKCMrpn\n",
       "k7YaTgSOccyrVVEzllCsEzQ2o/tm4DqKy+j+PGnG7Yxua3vOQrHhNS6j+z3A6RSb0T2f9Ki+M7qt\n",
       "Y7iB29Aak9H9KtJWwyIzuufWx1yLM7qtw3gJxQZrXEb30vp4RWd0X07acuiMbus4noFb4oxus8px\n",
       "AzdndJtVlBt4J2tcRvengG6Ky+jekZTRPRdndJs9yw28EzUuo/ufgZMpNqP7Q8CHSRnd85zRbdbP\n",
       "DbzT9Gd0B8VldB9QH3PMGd3PGbOmbtIuGGd0mw3DDbxTNCaj+yWkm577kZHRPWjMmnYh7SqZASyK\n",
       "3vAj7mbD8DbCdtef0X0/8AdS6FRuRvdW9Yzue4EVZGd0g2qarJpOIR0Icisw083bbNM8A29ngzO6\n",
       "Dyooo/vNpOyS4jK64e9IGSu3ArOjN7KCrMw6hRt4Oxqc0f1hICvmNQ3Jy0hNdg+Ky+ieQfpl8GLg\n",
       "iOiN7+eOadZJvITSTobO6P5mgRndd1B8RvfVpFm3m7fZKHkG3i4GZ3S/hoif5Q3XsIzu95Eyur9L\n",
       "Wud+LGdMs05WxJmYFwBvAR6PiD3yS7JR6c/o3hNYRPEZ3UcWlNG9J2k9fiLwDse8muUrYgnlQsDH\n",
       "qDXb4Izuu0kP45Q1o/tc0ozbGd2jIM3slg75jvSuvvT3md2trsnKJXsGHhE3Kc0CrRmqldF9JPBx\n",
       "nNE9aqlZzz0blu3a/+6CXaSZ+Pg328Br4FUyOKP7H4lYnj/ksxndU4B3RXBL9pg17Vsfcx3O6B6j\n",
       "aT2Dmzek190LATdwA5rUwCUtHvCyLyL6mnHdtiFNIcWnzgdOBZYS8ee8IdmWFGT1LlJ+yfkR5AVZ\n",
       "1bQ9cBrwZuAjwCUOnRqrqROHfn/KpObWYc0iqQvoGs13mtLAI2JxM67TdgZndH+f4jO6r6S4jO6j\n",
       "SL9kvoIzuguwet3Q769Z29w6rFnqE9u+Da+V7nFtkpdQyqo/o/t5wOFE3Jw/5LMZ3U/TmIzuA5zR\n",
       "XZRVS2DBLoOXUeavgJVLW1eTlY0yd5wh6evAgcD/IKXRnRwRFw74eUSEsi7SSQZndC8GvlBwRvdJ\n",
       "pIzuvCArZ3Q3XLqRudPCtGyyZi2sXOobmJ1jJL0zu4EXUYQxVEb3vzYgo/uUCJ7KGvO5Gd2nOaPb\n",
       "rHgj6Z1eQimDwRndbyXih/lDPpvR/QTQFcFPssd0RrdZqbiBt1JjM7pfS5opO6PbrE05zKoVBmd0\n",
       "r6H4jO5fAjOc0W3W3jwDb7b+jO4ncUa3mWVwA2+WwRndxwOXFpzRfWwEV2eX6Yxus8rwEkqjDZ3R\n",
       "nXXAwjAZ3VnN2xndZtXjGXgjDc7onkvEz/OGG5TRfQewVwQrs8Z0RrdZZbmBN0J/Rvcs4Fic0W1m\n",
       "DeAllCKljO6TSTGvdwG7F5jR/QPSDNkZ3WYGeAZejP6M7rNIjbsRGd0zndFtZgO5geeSXkF6OnFn\n",
       "Ukb3DflDOqPbzDbPSyhjJU1BOg24hTRDnpXbvCW2lVgKLAcuAfbObd6qaXvVdCFwOekUn/3dvM3a\n",
       "g2fgo5WWS95NtTK6v0xaLnFGt1kbcQMfDWkPBmd0/yB/SGd0m9nYuIGPRMrorpFuKvYCXyx5Rve+\n",
       "pCCrK53Rbda+3MA35bkZ3bs1IKN7RoEZ3ceTMrrnOaPbrP1lN3BJB5Nujo0Dzo+IT2dXVQb9Gd3P\n",
       "AG8h4s78IRue0T3HGd1mnSPrRB5J44CfAm8Afk16vPs9Ef1rrmU/kWem1D0NeqbCxNWw7oXw5Yvg\n",
       "9aSM7pOAr5Y8o3s6KaP7upzxipCOAJvWk05UX70OVi3xEWBmY9OME3nmAL+IiIfqF/wG8HagEjfN\n",
       "Zkrdc+HsZfDswbFr4A0Pwrenw3Qi8pY2xATSo/QfAc4DFkTwh6wxa5pM+sVyFGm9+7DojT/ljFmE\n",
       "1Lznnj34EN4Fu0gzcRM3a4zcBv4SYGBO9MPAPpljNs006BnYvAGmwLgPwaRr85v3waSljZ8B+xSc\n",
       "0X0LsGf0xsM5YxZrWs/g5g3pdfdCwA3crAFyG/iIlgEkLR7wsi8i+jKvW4hdYJuh3p8Ck8Y6Zj2j\n",
       "+yxgJo3J6P5A9Jbjz2+wqROHfn/KmP8szTqJpC6gazTfyW3gvwamDXg9jTQLHyQiFmdep1jSVsCi\n",
       "T8Orh/rxGlg7+iGZDJwIHAN8Fjg8gnVZZda0DWm3ygdI+SWfj954OmfMxlk9zP/WNaP+szTrRPWJ\n",
       "bd+G15J6N/ed3Efpfwi8XNLOSk3x3cC3M8dsrJTR/SOg6+PwzwsYvLQxH1asTA/BjHA4JHEoaRfI\n",
       "DGB2BJ/Kad6qSarp/aR7CduRMrqXlLd5A6xaAgs2WiaavwJWjvjP0sxGJ2sXCoCkQ+jfRviliDh1\n",
       "o5+XYxfK4IzuRURcDelG5k6wcApMWgNrV8LS+2JkB/dKTCctbbwEWNiAjO5jqhTzmm5k7rQwLZus\n",
       "WQsrl/oGptnYjKR3ZjfwIopocAGTgBOAHtIvms8Qkbe0IaYCHyPll3wSOCeC9Vlj1rQdaZnknaT8\n",
       "kguiN+9pTzOrrmZsIyyvwRndd5IyuvOOH0sZ3e8lHT/WiIzuS3FGt5mNUHs28P6M7pcCC4j4Xv6Q\n",
       "zCKtjTuj28xKob3ywAdndC8nZXRnNe96Rvc5wPU4o9vMSqQ9ZuCDM7pvxBndZtYBqt/AndFtZh2q\n",
       "ug28cRndpwKH4IxuMyu56jXwwRnd36K4jO6jSFsDndFtZpVQrQbemIzuA0lLG87oNrNKqUYDl15I\n",
       "mnEXmdG9I+mm536kWfJlBWd095Qho9vM2le5txFK45GOBn4CrCZldH8lp3lLTJA4EbgXWEFaLrk0\n",
       "p3mrpsmq6RTgNtIWxj3cvM2s0co7A5f2Jy2XPAkcRET+0kZjMroPJWWs3ErpMrrNrJ2Vr4FLOwCn\n",
       "AwcAHwYuJTOwpcEZ3X8FHFHOjG4za2flWUKRtkI6gRT1+itgBhH/ntO8JSZL1Eixt7eTskuymrdq\n",
       "2kY1nQH8J3AVMNvN28xaoRwz8JTRvQT4JTCXiJ/nDYeAvyXNum8nZXTnBVml5ZL3kYKsvkvK6H4s\n",
       "Z0wzsxytbeCDM7qPBa4uYLlkYEb3vAIzupeSjlp7R5Uyus2sfbVmCUWahHQyKeb1LmB3Iq7KXC6Z\n",
       "KnE6cDNwHbBnbvNWTduppnNJM+6LgH3cvM2sLMY8A5d0GLCYtOd574jYfF7I4Izuu0gZ3b8aaw1p\n",
       "yIZldG8IsnJGt5mVUs4Syo9JW+i+MKJP92d07wz8IxE3ZFy7PuSzGd1b0+YZ3em4smk96fT31etg\n",
       "1RIfV2bW2cbcwCPiQdgwqd6MlNE9nxQUtZSIP4/1umk4tiWdYHMY6dT28yPIC7Kqaft6fW8mnS5/\n",
       "SVlCp1Lznns2LNu1/90Fu0gzcRM361zNuom5A8VndF9BMRnd44GjKXVG97Sewc0b0uvuhYAbuFmH\n",
       "2mQDl7Sc9KDKxj4aEVeN9CJK2wP/iTRb74sY/b7pARnd6ykuo7uLtATzKKXO6J46cej3p0xqbh1m\n",
       "1iiSuoCu0Xxnkw08It6YUc/AcRaP9bsbZXSfSMrozg2dqlhG9+p1Q7+/Zm1z6zCzRqlPbPs2vJbU\n",
       "u7nvFLWNcAQL4aMcUIyX6CEFWf0OmB7BVzNDpyaoppOAe4CfArtFb1xR7uYNsGoJLNgot2X+Cli5\n",
       "tDX1mFkZaKxbryUdSnpg5gXAU8DdEXHIEJ+LiBhVgx+Q0f040BPB/WMqcuCYNR1C2gXzAHBc1TK6\n",
       "043MnRamZZM1a2HlUt/ANGtfI+mdY27gRRbR/9lnM7pfQ8rovryA5ZK/Ju07nwEscsyrmVXBSHpn\n",
       "KcKsBmR03wP8grS7JOuAhQEZ3beTol6d0W1mbaXlYVYbZXTv64xuM7ORaVkD3yije1EE12SP6Yxu\n",
       "M+sgTV9CkZgksRi4g/6M7qzmXc/o/gzO6DazDtK0GfiAjO4z6c/oXpU1pjO6zayDNaWBS7yStLSx\n",
       "I3BkgRnd5wATcUa3mXWgpmwjhPgN8Eng3AjWZ41X03akIKt3kvJLLojeyAqyMjMrm5FsI2zWEsoe\n",
       "BWV0H0lq3s7oNrOO15QGXkDzLmVGt5lZK7V8H/im1DO6TwPeRMkyus3MWq2UDVw1bQkcRakzus3M\n",
       "Wqt0DVw1HUQKsnqEUmd0m5m1VmkaePUyus3MWqvlDVw1TSA17OOBc4F50Rt/bG1VZmbl19IGrpq6\n",
       "SUFW9wNzqpbRbWbWSmNu4JLOAN4K/BlYAXwwIp4a0Xdr2oUUZDUd6HHMq5nZ6OWEWV0P7B4Rs0hR\n",
       "sP+yuS8MyOi+DbiFEmV01w8ULb0q1FmFGsF1Fs11Nt+YG3hELI+IZ+ovbyPlnAxJNUk1vYN0nNnL\n",
       "SRndp0Vv/Gms12+ArlYXMEJdrS5gBLpaXcAIdbW6gBHqanUBI9TV6gJGqKvVBRSlqDXwecDXN/Hz\n",
       "60kZ3R9wzKuZWTE22cAlLSc13o19NCKuqn/mX4E/R8TXNjHU1cDnozeygqzMzKxfVhqhpCOABcDr\n",
       "I2LdMJ/xXm4zszFoWBqhpIOBE4ADh2veIynAzMzGZswzcEk/B7YCNkS63hoRRxVVmJmZbVrDD3Qw\n",
       "M7PGaMqhxpLOkPSApHslXSHpec247mhIOkzSTyT9RdJera5nY5IOlvSgpJ9LOrHV9QxF0gWSHpP0\n",
       "41bXsimSpkn6fv3/7/sk9bS6pqFImijpNkn3SLpf0qmtrmk4ksZJulvSVa2uZVMkPSTpR/Vab291\n",
       "PUOR9HxJl9V75v2S9h3us806lX7UD/20wI+BQ0kn25eKpHGkAy0OBnYD3iNpRmurGtKFpBrLbj1w\n",
       "XETsTgpPO7qMf571e0sHRcSewKuAgyS9tsVlDWcRKRKj7P9JH0BXRMyOiDmtLmYYZwPXRsQM0v/v\n",
       "wyayNqWBj+ahn1aJiAcj4metrmMYc4BfRMRDEbEe+Abw9hbX9BwRcRPwX62uY3Mi4tGIdKpTRKwh\n",
       "/QuyQ2urGlrEs8FuWwHj6L/nVBqSdgS6gfOBKmxaKG2N9dWJ/SPiAoCIeHpTESXNmoEPNA+4tgXX\n",
       "rbKXAKuEvdvRAAACK0lEQVQGvH64/p5lkrQzMJs0sSgdSVtIugd4DPh+RNzf6pqGcBZpR9ozm/tg\n",
       "CQRwg6QfSlrQ6mKG8DLgCUkXSrpL0jJJk4f7cGENXNJyST8e4q+/GfCZkTz00zAjqbGkyv6fpZUk\n",
       "aQpwGbCoPhMvnYh4pr6EsiNwQNlyPCS9FXg8Iu6mxDPbAfaLiNnAIaSls/1bXdBGxgN7AZ+PiL2A\n",
       "PwAnberDhYiIN27q5/WHfrqB1xd1zdHaXI0l9mtg2oDX00izcBsjSVsClwMXR8S3Wl3P5kTEU5Ku\n",
       "AV4N9LW4nIFeA7xNUjcwEdhG0kUR8Q8trmtIEfFI/e9PSLqStDx5U2urGuRh4OGIuKP++jI20cCb\n",
       "tQtlw0M/b9/UQz8lUraZxA+Bl0vaWdJWwLuBb7e4psqSJOBLwP0R8blW1zMcSS+Q9Pz6P08C3gjc\n",
       "3dqqBouIj0bEtIh4GXA4cGNZm7ekyZKm1v95a9Jh6aXaMRURjwKrJL2i/tYbgJ8M9/lmrYEvBaYA\n",
       "y+vbdz7fpOuOmKRDJa0i7Uq4RlIpYm4h3cgAjgG+S7rT/82I8p0VKunrpJjgV0haJemDra5pGPsB\n",
       "7yft6ri7/lcZd8+8GLixvgZ+G3BVRHyvxTVtTpmX+7YHbhrw53l1RFzf4pqGshC4RNK9pF0onxru\n",
       "g36Qx8ysolqxC8XMzArgBm5mVlFu4GZmFeUGbmZWUW7gZmYV5QZuZlZRbuBmZhXlBm5mVlH/DYXM\n",
       "z2nC5qRuAAAAAElFTkSuQmCC\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fbcb01f62e8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def plotSVM(X,t,wb):\n",
    "    plt.plot(X[t>0,0],X[t>0,1], 'ro')\n",
    "    plt.plot(X[t<0,0],X[t<0,1], 'bo')\n",
    "    plt.axis([-2, 6, -2, 7])\n",
    "    x = np.arange(-2,6,1)\n",
    "    y0 = -1*wb[0]/wb[1]*x-wb[2]/wb[1]\n",
    "    y1 = -1*wb[0]/wb[1]*x-(wb[2]+1)/wb[1]\n",
    "    y_1 = -1*wb[0]/wb[1]*x-(wb[2]-1)/wb[1]\n",
    "    plt.plot(x,y0)\n",
    "    plt.plot(x,y1)\n",
    "    plt.plot(x,y_1)\n",
    "    \n",
    "plotSVM(X_,t_,wb_opt)  ### PROVIDE THIS PLOT ###"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## New Data Set\n",
    "\n",
    "You are now given the following new data set."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Generating the data\n",
    "N_half = 20\n",
    "u1 = random.rand(N_half)\n",
    "x1 = cos(2*pi*u1) + .3*random.rand(N_half)\n",
    "y1 = sin(2*pi*u1) + .3*random.rand(N_half)\n",
    "u2 = random.rand(N_half)\n",
    "x2 = 2.*cos(2*pi*u2) + .3*random.rand(N_half)\n",
    "y2 = 2.*sin(2*pi*u2) + .3*random.rand(N_half)\n",
    "\n",
    "# New Data\n",
    "X_c = transpose(vstack((hstack((x1,x2)),hstack((y1,y2)))))\n",
    "t_c = hstack((ones(N_half),-ones(N_half)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Remark that the data is distributed on two circles, centered on zero, with different radii."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[-3, 3, -3, 3]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": [
       "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\n",
       "AElFTkSuQmCC\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f37ddd0c5f8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plot new data\n",
    "plt.plot(X_c[t_c>0,0],X_c[t_c>0,1], 'ro')\n",
    "plt.plot(X_c[t_c<0,0],X_c[t_c<0,1], 'bo')\n",
    "plt.axis([-3, 3, -3, 3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[-1, 6, -1, 6]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": [
       "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\n",
       "YII=\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fbc8e3a6c50>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#X_transformed = 2.5*transpose(vstack((hstack((np.abs(x1),np.abs(x2))),hstack((np.abs(y1),np.abs(y2)))))) ### CHANGE THIS LINE ####\n",
    "#X_transformed = transpose(vstack((hstack((sqrt(x1**2+y1**2),sqrt(x2**2+y2**2))),np.zeros(2*N_half))))\n",
    "X_transformed = transpose(vstack((hstack((x1**2,x2**2)),hstack((y1**2,y2**2)))))\n",
    "\n",
    "### prbly other transormation\n",
    "plt.plot(X_transformed[t_c>0,0],X_transformed[t_c>0,1], 'ro')\n",
    "plt.plot(X_transformed[t_c<0,0],X_transformed[t_c<0,1], 'bo')\n",
    "plt.axis([-1, 6, -1, 6])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(40, 2)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "shape(X_transformed)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Plotting the result in the transformed space. \n",
    "(Lines are commented, because code does not compile, until X has been correctly transformed.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": [
       "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\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fbc8e3a6a58>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "wb_opt_c = optimizeSVM(X_transformed,t_c)\n",
    "plotSVM(X_transformed,t_c,wb_opt_c)  ### PROVIDE THIS PLOT ###"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Feel free (not mandatory!) to rewrite the function plotSVM to plot the data and the separation curve, not in the transformed space (as above), but in the original space."
   ]
  }
 ],
 "metadata": {
  "annotations": {
   "author": "",
   "categories": [
    "intelligent-systems-1-2015"
   ],
   "date": "2015-04-23",
   "location": "Beginning of next lecture",
   "parent": "IS_SS2015",
   "submission_date": "2015-04-30",
   "subtitle": "Exercise Sheet 2, Support Vector Machines",
   "tags": [
    "IntelligenSystems",
    "Course"
   ],
   "title": "Intelligent Systems 1 - Summer Semester 2015"
  },
  "celltoolbar": "Edit 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.4.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
