Skip to content
Snippets Groups Projects
01_introduction.ipynb 736 KiB
Newer Older
  • Learn to ignore specific revisions
  • schmittu's avatar
    schmittu committed
    {
     "cells": [
    
      {
       "cell_type": "code",
    
       "execution_count": 1,
    
       "metadata": {},
       "outputs": [
        {
         "data": {
          "text/html": [
           "<style>\n",
           "    \n",
           "    @import url('http://fonts.googleapis.com/css?family=Source+Code+Pro');\n",
           "    \n",
           "    @import url('http://fonts.googleapis.com/css?family=Kameron');\n",
           "    @import url('http://fonts.googleapis.com/css?family=Crimson+Text');\n",
           "    \n",
           "    @import url('http://fonts.googleapis.com/css?family=Lato');\n",
           "    @import url('http://fonts.googleapis.com/css?family=Source+Sans+Pro');\n",
           "    \n",
           "    @import url('http://fonts.googleapis.com/css?family=Lora'); \n",
           "\n",
           "    \n",
           "    body {\n",
           "        font-family: 'Lora', Consolas, sans-serif;\n",
           "       \n",
           "        -webkit-print-color-adjust: exact important !;\n",
           "        \n",
           "      \n",
           "       \n",
           "    }\n",
           "    \n",
           "    .alert-block {\n",
           "        width: 95%;\n",
           "        margin: auto;\n",
           "    }\n",
           "    \n",
           "    .rendered_html code\n",
           "    {\n",
           "        color: black;\n",
           "        background: #eaf0ff;\n",
           "        background: #f5f5f5; \n",
           "        padding: 1pt;\n",
           "        font-family:  'Source Code Pro', Consolas, monocco, monospace;\n",
           "    }\n",
           "    \n",
           "    p {\n",
           "      line-height: 140%;\n",
           "    }\n",
           "    \n",
           "    strong code {\n",
           "        background: red;\n",
           "    }\n",
           "    \n",
           "    .rendered_html strong code\n",
           "    {\n",
           "        background: #f5f5f5;\n",
           "    }\n",
           "    \n",
           "    .CodeMirror pre {\n",
           "    font-family: 'Source Code Pro', monocco, Consolas, monocco, monospace;\n",
           "    }\n",
           "    \n",
           "    .cm-s-ipython span.cm-keyword {\n",
           "        font-weight: normal;\n",
           "     }\n",
           "     \n",
           "     strong {\n",
           "         background: #f5f5f5;\n",
           "         margin-top: 4pt;\n",
           "         margin-bottom: 4pt;\n",
           "         padding: 2pt;\n",
           "         border: 0.5px solid #a0a0a0;\n",
           "         font-weight: bold;\n",
           "         color: darkred;\n",
           "     }\n",
           "     \n",
           "    \n",
           "    div #notebook {\n",
           "        # font-size: 10pt; \n",
           "        line-height: 145%;\n",
           "        }\n",
           "        \n",
           "    li {\n",
           "        line-height: 145%;\n",
           "    }\n",
           "\n",
           "    div.output_area pre {\n",
           "        background: #fff9d8 !important;\n",
           "        padding: 5pt;\n",
           "       \n",
           "       -webkit-print-color-adjust: exact; \n",
           "        \n",
           "    }\n",
           " \n",
           "    \n",
           " \n",
           "    h1, h2, h3, h4 {\n",
           "        font-family: Kameron, arial;\n",
           "\n",
           "\n",
           "    }\n",
           "    \n",
           "    div#maintoolbar {display: none !important;}\n",
           "</style>\n"
          ],
          "text/plain": [
           "<IPython.core.display.HTML object>"
          ]
         },
    
         "execution_count": 1,
    
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
    schmittu's avatar
    schmittu committed
        "# IGNORE THIS CELL WHICH CUSTOMIZES LAYOUT AND STYLING OF THE NOTEBOOK !\n",
        "import matplotlib.pyplot as plt\n",
        "%matplotlib inline\n",
        "%config InlineBackend.figure_format = 'retina'\n",
        "import warnings\n",
        "warnings.filterwarnings('ignore', category=FutureWarning)\n",
    
    schmittu's avatar
    schmittu committed
        "warnings.filterwarnings = lambda *a, **kw: None\n",
    
        "from IPython.core.display import HTML; HTML(open(\"custom.html\", \"r\").read())"
       ]
      },
    
    schmittu's avatar
    schmittu committed
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
    schmittu's avatar
    schmittu committed
        "# Chapter 1: General Introduction to machine learning (ML)"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
    schmittu's avatar
    schmittu committed
        "## ML = \"learning models from data\"\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "### About models\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "A \"model\" allows us to explain observations and to answer questions. For example:\n",
        "\n",
    
        "   1. Where will my car at given velocity stop if I apply break now?\n",
        "   2. Where on the night sky will I see the moon tonight?\n",
        "   3. Is the email I received spam?\n",
        "   4. Which article \"X\" should I recommend to a customer \"Y\"?\n",
    
    schmittu's avatar
    schmittu committed
        "   \n",
    
    schmittu's avatar
    schmittu committed
        "- The first two questions can be answered based on existing physical models (formulas). \n",
        "\n",
        "- For the  questions 3 and 4 it is difficult to develop explicitly formulated models. \n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "### What is needed to apply ML ?\n",
        "\n",
        "Problems 3 and 4 have the following in common:\n",
        "\n",
        "- No exact model known or implementable because we have a vague understanding of the problem domain.\n",
        "- But enough data with sufficient and implicit information is available.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "E.g. for the spam email example:\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "- We have no explicit formula for such a task (and devising one would boil down to lots of trial with different statistics or scores and possibly weighting of them).\n",
    
        "- We have a vague understanding of the problem domain because we know that some words are specific to spam emails and others are specific to my personal and work-related emails.\n",
        "- My mailbox is full with examples of both spam and non-spam emails.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "**In such cases machine learning offers approaches to build models based on example data.**\n",
        "\n",
    
        "<div class=\"alert alert-block alert-info\">\n",
        "<i class=\"fa fa-info-circle\"></i>\n",
    
        "The closely-related concept of <strong>data mining</strong> usually means use of predictive machine learning models to explicitly discover previously unknown knowledge from a specific data set, such as, for instance, association rules between customer and article types in the Problem 4 above.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "\n",
        "\n",
        "## ML: what is \"learning\" ?\n",
        "\n",
    
        "To create a predictive model, we must first **train** such a model on given data. \n",
    
        "<div class=\"alert alert-block alert-info\">\n",
        "<i class=\"fa fa-info-circle\"></i>\n",
        "Alternative names for \"to train\" a model are \"to <strong>fit</strong>\" or \"to <strong>learn</strong>\" a model.\n",
        "</div>\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "All ML algorithms have in common that they rely on internal data structures and/or parameters. Learning then builds up such data structures or adjusts parameters based on the given data. After that such models can be used to explain observations or to answer questions.\n",
        "\n",
        "The important difference between explicit models and models learned from data:\n",
        "\n",
        "- Explicit models usually offer exact answers to questions\n",
        "- Models we learn from data usually come with inherent uncertainty."
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "## Some history\n",
        "\n",
    
    schmittu's avatar
    schmittu committed
        "Some parts of ML are older than you might think. This is a rough time line with a few selected achievements from this field:\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "    1805: Least squares regression\n",
        "    1812: Bayes' rule\n",
    
    schmittu's avatar
    schmittu committed
        "    1913: Markov Chains\n",
    
    schmittu's avatar
    schmittu committed
        "    1951: First neural network\n",
    
        "    1957-65: \"k-means\" clustering algorithm\n",
        "    1959: Term \"machine learning\" is coined by Arthur Samuel, an AI pioneer\n",
    
    schmittu's avatar
    schmittu committed
        "    1969: Book \"Perceptrons\": Limitations of Neural Networks\n",
    
        "    1974-86: Neural networks learning breakthrough: backpropagation method\n",
    
        "    1984: Book \"Classification And Regression Trees\"\n",
    
        "    1995: Randomized Forests and Support Vector Machines methods\n",
        "    1998: Public appearance: first ML implementations of spam filtering methods; naive Bayes Classifier method\n",
        "    2006-12: Neural networks learning breakthrough: deep learning\n",
    
    schmittu's avatar
    schmittu committed
        "    \n",
        "So the field is not as new as one might think, but due to \n",
        "\n",
        "- more available data\n",
        "- more processing power \n",
        "- development of better algorithms \n",
        "\n",
        "more applications of machine learning appeared during the last 15 years."
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
        "## Machine learning with Python\n",
        "\n",
    
        "Currently (2018) `Python` is the  dominant programming language for ML. Especially the advent of deep-learning pushed this forward. First versions of frameworks such as `TensorFlow` or `PyTorch` got early `Python` releases.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "The prevalent packages in the Python eco-system used for ML include:\n",
        "\n",
    
        "- `pandas` for handling tabular data\n",
    
    schmittu's avatar
    schmittu committed
        "- `matplotlib` and `seaborn` for plotting\n",
        "- `scikit-learn` for classical (non-deep-learning) ML\n",
    
        "- `TensorFlow`, `PyTorch` and `Keras` for deep-learning.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "`scikit-learn` is very comprehensive and the online-documentation itself provides a good introducion into ML."
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "## ML lingo: What are \"features\" ?\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "A typical and very common situation is that our data is presented as a table, as in the following example:"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": 2,
    
    schmittu's avatar
    schmittu committed
       "metadata": {},
    
    schmittu's avatar
    schmittu committed
       "outputs": [
        {
         "data": {
          "text/html": [
           "<div>\n",
           "<style scoped>\n",
           "    .dataframe tbody tr th:only-of-type {\n",
           "        vertical-align: middle;\n",
           "    }\n",
           "\n",
           "    .dataframe tbody tr th {\n",
           "        vertical-align: top;\n",
           "    }\n",
           "\n",
           "    .dataframe thead th {\n",
           "        text-align: right;\n",
           "    }\n",
           "</style>\n",
           "<table border=\"1\" class=\"dataframe\">\n",
           "  <thead>\n",
           "    <tr style=\"text-align: right;\">\n",
           "      <th></th>\n",
           "      <th>alcohol_content</th>\n",
           "      <th>bitterness</th>\n",
           "      <th>darkness</th>\n",
           "      <th>fruitiness</th>\n",
           "      <th>is_yummy</th>\n",
           "    </tr>\n",
           "  </thead>\n",
           "  <tbody>\n",
           "    <tr>\n",
           "      <th>0</th>\n",
           "      <td>3.739295</td>\n",
           "      <td>0.422503</td>\n",
           "      <td>0.989463</td>\n",
           "      <td>0.215791</td>\n",
           "      <td>0</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>1</th>\n",
           "      <td>4.207849</td>\n",
           "      <td>0.841668</td>\n",
           "      <td>0.928626</td>\n",
           "      <td>0.380420</td>\n",
           "      <td>0</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>2</th>\n",
           "      <td>4.709494</td>\n",
           "      <td>0.322037</td>\n",
           "      <td>5.374682</td>\n",
           "      <td>0.145231</td>\n",
           "      <td>1</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>3</th>\n",
           "      <td>4.684743</td>\n",
           "      <td>0.434315</td>\n",
           "      <td>4.072805</td>\n",
           "      <td>0.191321</td>\n",
           "      <td>1</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>4</th>\n",
           "      <td>4.148710</td>\n",
           "      <td>0.570586</td>\n",
           "      <td>1.461568</td>\n",
           "      <td>0.260218</td>\n",
           "      <td>0</td>\n",
           "    </tr>\n",
           "  </tbody>\n",
           "</table>\n",
           "</div>"
          ],
          "text/plain": [
           "   alcohol_content  bitterness  darkness  fruitiness  is_yummy\n",
           "0         3.739295    0.422503  0.989463    0.215791         0\n",
           "1         4.207849    0.841668  0.928626    0.380420         0\n",
           "2         4.709494    0.322037  5.374682    0.145231         1\n",
           "3         4.684743    0.434315  4.072805    0.191321         1\n",
           "4         4.148710    0.570586  1.461568    0.260218         0"
          ]
         },
    
         "execution_count": 2,
    
    schmittu's avatar
    schmittu committed
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
    
    schmittu's avatar
    schmittu committed
       "source": [
        "import pandas as pd\n",
        "\n",
        "features = pd.read_csv(\"beers.csv\")\n",
        "features.head()"
       ]
      },
    
    schmittu's avatar
    schmittu committed
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "<div class=\"alert alert-block alert-warning\">\n",
        "<i class=\"fa fa-warning\"></i>&nbsp;<strong>Definitions</strong>\n",
        "<ul>\n",
        "    <li>every row of such a matrix is called a <strong>sample</strong> or <strong>feature vector</strong>;</li>\n",
        "    <li>the cells in a row are <strong>feature values</strong>;</li>\n",
        "    <li>every column name is called a <strong>feature name</strong> or <strong>attribute</strong>.</li>\n",
        "</ul>\n",
        "\n",
        "Features are also commonly called <strong>variables</strong>.\n",
        "</div>"
    
    schmittu's avatar
    schmittu committed
       ]
      },
    
    schmittu's avatar
    schmittu committed
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
    schmittu's avatar
    schmittu committed
        "This table shown holds five samples.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "The feature names are `alcohol_content`, `bitterness`, `darkness`, `fruitiness` and `is_yummy`.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "<div class=\"alert alert-block alert-warning\">\n",
        "<i class=\"fa fa-warning\"></i>&nbsp;<strong>More definitions</strong>\n",
        "<ul>\n",
        "    <li>The first four features have continuous numerical values within some ranges - these are called <strong>numerical features</strong>,</li>\n",
        "    <li>the <code>is_yummy</code> feature has only a finite set of values (\"categories\"): <code>0</code> (\"no\") and <code>1</code> (\"yes\") - this is called a <strong>categorical feature</strong>.</li>\n",
        "</ul>\n"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "A straight-forward application of machine-learning on the previous beer dataset is: **\"can we predict `is_yummy` from the other features\"** ?\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "<div class=\"alert alert-block alert-warning\">\n",
        "<i class=\"fa fa-warning\"></i>&nbsp;<strong>Even more definitions</strong>\n",
        "\n",
        "In context of the question above we call:\n",
        "<ul>\n",
        "    <li>the <code>alcohol_content</code>, <code>bitterness</code>, <code>darkness</code>, <code>fruitiness</code> features our <strong>input features</strong>, and</li>\n",
        "    <li>the <code>is_yummy</code> feature our <strong>target/output feature</strong> or a <strong>label</strong> of our data samples.\n",
        "        <ul>\n",
        "            <li>Values of categorical labels, such as <code>0</code> (\"no\") and <code>1</code> (\"yes\") here, are often called <strong>classes</strong>.</li>\n",
        "        </ul>\n",
        "    </li>\n",
        "</ul>"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "Most of the machine learning algorithms require that every sample is represented as a vector containing numbers. Let's look now at two examples of how one can create feature vectors from data which is not naturally given as vectors:\n",
    
        "\n",
        "1. Feature vectors from images\n",
        "2. Feature vectors from text.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "### 1st Example: How to represent images as feature vectors ?\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "In order to simplify our explanations we only consider grayscale images in this section. \n",
        "Computers represent images as matrices. Every cell in the matrix represents one pixel, and the numerical value in the matrix cell its gray value.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "So how can we represent images as vectors?\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "To demonstrate this we will now load a sample dataset that is included in `scikit-learn`:"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": 3,
    
    schmittu's avatar
    schmittu committed
       "metadata": {},
    
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "['DESCR', 'data', 'images', 'target', 'target_names']\n"
         ]
        }
       ],
    
    schmittu's avatar
    schmittu committed
       "source": [
    
        "from sklearn.datasets import load_digits\n",
        "\n",
    
        "dd = load_digits()\n",
        "print(dir(dd))"
    
    schmittu's avatar
    schmittu committed
       ]
      },
    
      {
       "cell_type": "code",
    
       "execution_count": 4,
    
       "metadata": {},
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "DESCR:\n",
    
          " .. _digits_dataset:\n",
          "\n",
          "Optical recognition of handwritten digits dataset\n",
          "--------------------------------------------------\n",
          "\n",
          "**Data Set Characteristics:**\n",
    
          "\n",
          "    :Number of Instances: 5620\n",
          "    :Number of Attributes: 64\n",
          "    :Attribute Information: 8x8 image of integer pixels in the range 0..16.\n",
          "    :Missing Attribute Values: None\n",
          "    :Creator: E. Alpaydin (alpaydin '@' boun.edu.tr)\n",
          "    :Date: July; 1998\n",
          "\n",
          "This is a copy of the test set of the UCI ML hand-written digits datasets\n",
    
          "http://archive.ics.uci. \n",
    
          "[...]\n"
         ]
        }
       ],
       "source": [
        "print(\"DESCR:\\n\", dd.DESCR[:500], \"\\n[...]\") # description of the dataset"
       ]
      },
    
    schmittu's avatar
    schmittu committed
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "Let's plot the first ten digits from this data set:"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": 5,
    
    schmittu's avatar
    schmittu committed
       "metadata": {},
    
    schmittu's avatar
    schmittu committed
       "outputs": [
        {
         "data": {
    
          "image/png": "iVBORw0KGgoAAAANSUhEUgAACPMAAAEZCAYAAAD4nfIqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzs3X+UJGZd5/vPN4lIgJAJYAD5kU6yAlHWDASRq14zAcKiqAl60SvrboYVxbMqyR7wEnFdEj27BPdKhouuhlVIxNXdzXGdiKJAkOBVBNeYyV5+hIhDByH80JAZQgi/kuf+UTXShvQkpOvpeqrq9TpnTk13ld9+TPOerq7+dlW11gIAAAAAAAAAAMzfEfM+AAAAAAAAAAAAMGGZBwAAAAAAAAAABmGZBwAAAAAAAAAABmGZBwAAAAAAAAAABmGZBwAAAAAAAAAABmGZBwAAAAAAAAAABmGZBwAAAAAAAAAABmGZBwAAAAAAAAAABmGZBwAAAAAAAAAABmGZBwAAAAAAAAA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MOpm/dk/AAAAAElFTkSuQmCC\n",
    
    schmittu's avatar
    schmittu committed
          "text/plain": [
    
           "<Figure size 1440x360 with 10 Axes>"
    
    schmittu's avatar
    schmittu committed
          ]
         },
         "metadata": {
    
           "height": 140,
           "width": 1145
    
    schmittu's avatar
    schmittu committed
          "needs_background": "light"
         },
         "output_type": "display_data"
        }
       ],
    
    schmittu's avatar
    schmittu committed
       "source": [
    
        "import matplotlib.pyplot as plt\n",
        "\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "plt.figure(figsize=(2 * N, 5))\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "for i, image in enumerate(dd.images[:N]):\n",
    
        "    plt.subplot(1, N, i + 1).set_title(dd.target[i])\n",
    
    schmittu's avatar
    schmittu committed
        "    plt.imshow(image, cmap=\"gray\")"
       ]
      },
    
    schmittu's avatar
    schmittu committed
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "The data is a set of 8 x 8 matrices with values 0 to 15 (black to white). The range 0 to 15 is fixed for this specific data set. Other formats allow e.g. values 0..255 or floating point values in the range 0 to 1."
    
    schmittu's avatar
    schmittu committed
       ]
      },
    
    schmittu's avatar
    schmittu committed
      {
       "cell_type": "code",
    
       "execution_count": 6,
    
    schmittu's avatar
    schmittu committed
       "metadata": {},
    
    schmittu's avatar
    schmittu committed
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
    
          "images[0].shape: (8, 8)\n",
    
          "images[0]:\n",
          " [[ 0.  0.  5. 13.  9.  1.  0.  0.]\n",
    
    schmittu's avatar
    schmittu committed
          " [ 0.  0. 13. 15. 10. 15.  5.  0.]\n",
          " [ 0.  3. 15.  2.  0. 11.  8.  0.]\n",
          " [ 0.  4. 12.  0.  0.  8.  8.  0.]\n",
          " [ 0.  5.  8.  0.  0.  9.  8.  0.]\n",
          " [ 0.  4. 11.  0.  1. 12.  7.  0.]\n",
          " [ 0.  2. 14.  5. 10. 12.  0.  0.]\n",
    
          " [ 0.  0.  6. 13. 10.  0.  0.  0.]]\n"
    
    schmittu's avatar
    schmittu committed
         ]
        }
       ],
    
    schmittu's avatar
    schmittu committed
       "source": [
    
        "print(\"images[0].shape:\", dd.images[0].shape) # dimensions of a first sample array\n",
    
        "print()\n",
        "print(\"images[0]:\\n\", dd.images[0]) # first sample array"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "To transform such an image to a feature vector we just have to flatten the matrix by concatenating the rows to one single vector of size 64:"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": 7,
    
    schmittu's avatar
    schmittu committed
       "metadata": {},
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
    
          "image_vector.shape: (64,)\n",
          "image_vector: [ 0.  0.  5. 13.  9.  1.  0.  0.  0.  0. 13. 15. 10. 15.  5.  0.  0.  3.\n",
    
    schmittu's avatar
    schmittu committed
          " 15.  2.  0. 11.  8.  0.  0.  4. 12.  0.  0.  8.  8.  0.  0.  5.  8.  0.\n",
          "  0.  9.  8.  0.  0.  4. 11.  0.  1. 12.  7.  0.  0.  2. 14.  5. 10. 12.\n",
          "  0.  0.  0.  0.  6. 13. 10.  0.  0.  0.]\n"
         ]
        }
       ],
       "source": [
    
        "image_vector = dd.images[0].flatten()\n",
        "print(\"image_vector.shape:\", image_vector.shape)\n",
        "print(\"image_vector:\", image_vector)"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
    
    schmittu's avatar
    schmittu committed
       "metadata": {},
       "source": [
    
        "### 2nd Example: How to present textual data as feature vectors?"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "If we start a machine learning project for texts, we first have to choose a dictionary (a set of words) for this project. The words in the dictionary are enumerated. The final representation of a text as a feature vector depends on this dictionary.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "Such a dictionary can be very large, but for the sake of simplicity we use a very small enumerated dictionary to explain the overall procedure:\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "\n",
        "| Word     | Index |\n",
        "|----------|-------|\n",
        "| like     | 0     |\n",
        "| dislike  | 1     |\n",
        "| american | 2     |\n",
        "| italian  | 3     |\n",
        "| beer     | 4     |\n",
        "| pizza    | 5     |\n",
        "\n",
    
        "To \"vectorize\" a given text we count the words in the text which also exist in the vocabulary and put the counts at the given `Index`.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "E.g. `\"I dislike american pizza, but american beer is nice\"`:\n",
        "\n",
    
    schmittu's avatar
    schmittu committed
        "| Word     | Index | Count |\n",
    
    schmittu's avatar
    schmittu committed
        "|----------|-------|-------|\n",
    
    schmittu's avatar
    schmittu committed
        "| like     | 0     | 0     |\n",
    
    schmittu's avatar
    schmittu committed
        "| dislike  | 1     | 1     |\n",
        "| american | 2     | 2     |\n",
        "| italian  | 3     | 0     |\n",
        "| beer     | 4     | 1     |\n",
        "| pizza    | 5     | 1     |\n",
        "\n",
    
        "The respective feature vector is the `Count` column, which is:\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "`[0, 1, 2, 0, 1, 1]`\n",
        "\n",
    
        "In real case scenarios the dictionary is much bigger, which often results in vectors with only few non-zero entries (so called **sparse vectors**)."
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "Below you find is a short code example to demonstrate how text feature vectors can be created with `scikit-learn`.\n",
        "<div class=\"alert alert-block alert-info\">\n",
        "<i class=\"fa fa-info-circle\"></i>\n",
        "Such vectorization is usually not done manually. Actually there are improved but more complicated procedures which compute multiplicative weights for the vector entries to emphasize informative words such as, e.g., <a href=\"https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.TfidfVectorizer.html\">\"term frequency-inverse document frequency\" vectorizer</a>.\n",
        "</div>"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": 8,
    
    schmittu's avatar
    schmittu committed
       "metadata": {},
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "[0 1 2 0 1 1]\n"
         ]
        }
       ],
       "source": [
        "from sklearn.feature_extraction.text import CountVectorizer\n",
        "from itertools import count\n",
        "\n",
    
        "vocabulary = {\n",
        "    \"like\": 0,\n",
        "    \"dislike\": 1,\n",
        "    \"american\": 2,\n",
        "    \"italian\": 3,\n",
        "    \"beer\": 4,\n",
        "    \"pizza\": 5,\n",
        "}\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "vectorizer = CountVectorizer(vocabulary=vocabulary)\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "# this how one can create a count vector for a given piece of text:\n",
    
        "vector = vectorizer.fit_transform([\n",
        "    \"I dislike american pizza. But american beer is nice\"\n",
        "]).toarray().flatten()\n",
    
    schmittu's avatar
    schmittu committed
        "print(vector)"
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
    schmittu's avatar
    schmittu committed
        "## Taxonomy of machine learning\n",
        "\n",
    
    schmittu's avatar
    schmittu committed
        "Most applications of ML belong to two categories: **supervised** and **unsupervised** learning.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "### Supervised learning \n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "In supervised learning the data comes with an additional target/label value that we want to predict. Such a problem can be either \n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "- **classification**: we want to predict a categorical value.\n",
    
    schmittu's avatar
    schmittu committed
        "    \n",
    
    schmittu's avatar
    schmittu committed
        "- **regression**: we want to predict numbers in a given range.\n",
    
    schmittu's avatar
    schmittu committed
        "    \n",
    
    schmittu's avatar
    schmittu committed
        "  \n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "Examples of supervised learning:\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "- Classification: predict the class `is_yummy`  based on the attributes `alcohol_content`,\t`bitterness`, \t`darkness` and `fruitiness` (a standard two-class problem).\n",
    
        "\n",
        "- Classification: predict the digit-shown based on a 8 x 8 pixel image (a multi-class problem).\n",
        "\n",
        "- Regression: predict temperature based on how long sun was shining in the last 10 minutes.\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "\n",
    
        "\n",
        "<table>\n",
        "    <tr>\n",
        "    <td><img src=\"./classification-svc-2d-poly.png\" width=400px></td>\n",
        "    <td><img src=\"./regression-lin-1d.png\" width=400px></td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "        <td><center>Classification</center></td>\n",
        "        <td><center>Linear regression</center></td>\n",
        "    </tr>\n",
        "</table>\n"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
        "### Unsupervised learning \n",
        "\n",
    
        "In unsupervised learning the training data consists of samples without any corresponding target/label values and the aim is to find structure in data. Some common applications are:\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "- Clustering: find groups in data.\n",
    
    schmittu's avatar
    schmittu committed
        "- Density estimation, novelty detection: find a probability distribution in your data.\n",
    
    schmittu's avatar
    schmittu committed
        "- Dimension reduction (e.g. PCA): find latent structures in your data.\n",
        "\n",
    
        "Examples of unsupervised learning:\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "- Can we split up our beer data set into sub-groups of similar beers?\n",
    
        "- Can we reduce our data set because groups of features are somehow correlated?\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
    schmittu's avatar
    schmittu committed
        "<table>\n",
        "    <tr>\n",
    
        "    <td><img src=\"./cluster-image.png/\" width=400px></td>\n",
        "    <td><img src=\"./nonlin-pca.png/\" width=400px></td>\n",
    
    schmittu's avatar
    schmittu committed
        "    </tr>\n",
        "    <tr>\n",
        "        <td><center>Clustering</center></td>\n",
        "        <td><center>Dimension reduction: detecting 2D structure in 3D data</center></td>\n",
        "    </tr>\n",
        "</table>\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "\n",
        "\n",
        "This course will only introduce concepts and methods from **supervised learning**."
    
    schmittu's avatar
    schmittu committed
       ]
      },
    
    schmittu's avatar
    schmittu committed
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "## How to apply machine learning in practice?\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
        "Application of machine learning in practice consists of several phases:\n",
        "\n",
    
        "1. Understand and clean your data\n",
    
    schmittu's avatar
    schmittu committed
        "1. Learn / train a model \n",
    
    schmittu's avatar
    schmittu committed
        "2. Analyze model for its quality / performance\n",
        "2. Apply this model to new incoming data\n",
        "\n",
    
        "In practice steps 1. and 2. are iterated for different machine learning algorithms with different configurations until performance is optimal or sufficient. \n",
        "\n",
        "\n",
        "<div class=\"alert alert-block alert-warning\">\n",
        "<i class=\"fa fa-warning\"></i>&nbsp;<strong>Garbage in / garbage out</strong>\n",
        "\n",
        "The principle of \"garbage in, garbage out\" also applies in machine learning.\n",
        "\n",
        "Cleaning data to remove strong outliers or erroneous entries is crucial in real-world problems and  can be the most time-consuming part.\n",
        "\n",
        "</div>"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "# Hands-on section"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
        "Our example beer data set reflects the very personal opinion of one of the tutors which beer he likes and which not. To learn a predictive model and to understand influential factors all beers went through some lab analysis to measure alcohol content, bitterness, darkness and fruitiness."
       ]
      },
    
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
    
        "### 1. Load the data and show the overall structure using `pandas`"
    
    schmittu's avatar
    schmittu committed
      {
       "cell_type": "code",
    
       "execution_count": 9,
    
       "metadata": {},
       "outputs": [
        {
         "name": "stdout",
         "output_type": "stream",
         "text": [
          "(225, 5)\n"
         ]
        }
       ],
       "source": [
        "import pandas as pd\n",
        "\n",
        "# read some data\n",
        "beer_data = pd.read_csv(\"beers.csv\")\n",
        "print(beer_data.shape)"
       ]
      },
    
    schmittu's avatar
    schmittu committed
      {
       "cell_type": "code",
    
       "execution_count": 10,
    
    schmittu's avatar
    schmittu committed
       "metadata": {},
       "outputs": [
        {
         "data": {
          "text/html": [
           "<div>\n",
           "<style scoped>\n",
           "    .dataframe tbody tr th:only-of-type {\n",
           "        vertical-align: middle;\n",
           "    }\n",
           "\n",
           "    .dataframe tbody tr th {\n",
           "        vertical-align: top;\n",
           "    }\n",
           "\n",
           "    .dataframe thead th {\n",
           "        text-align: right;\n",
           "    }\n",
           "</style>\n",
           "<table border=\"1\" class=\"dataframe\">\n",
           "  <thead>\n",
           "    <tr style=\"text-align: right;\">\n",
           "      <th></th>\n",
           "      <th>alcohol_content</th>\n",
           "      <th>bitterness</th>\n",
           "      <th>darkness</th>\n",
           "      <th>fruitiness</th>\n",
           "      <th>is_yummy</th>\n",
           "    </tr>\n",
           "  </thead>\n",
           "  <tbody>\n",
           "    <tr>\n",
           "      <th>0</th>\n",
           "      <td>3.739295</td>\n",
           "      <td>0.422503</td>\n",
           "      <td>0.989463</td>\n",
           "      <td>0.215791</td>\n",
           "      <td>0</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>1</th>\n",
           "      <td>4.207849</td>\n",
           "      <td>0.841668</td>\n",
           "      <td>0.928626</td>\n",
           "      <td>0.380420</td>\n",
           "      <td>0</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>2</th>\n",
           "      <td>4.709494</td>\n",
           "      <td>0.322037</td>\n",
           "      <td>5.374682</td>\n",
           "      <td>0.145231</td>\n",
           "      <td>1</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>3</th>\n",
           "      <td>4.684743</td>\n",
           "      <td>0.434315</td>\n",
           "      <td>4.072805</td>\n",
           "      <td>0.191321</td>\n",
           "      <td>1</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>4</th>\n",
           "      <td>4.148710</td>\n",
           "      <td>0.570586</td>\n",
           "      <td>1.461568</td>\n",
           "      <td>0.260218</td>\n",
           "      <td>0</td>\n",
           "    </tr>\n",
           "  </tbody>\n",
           "</table>\n",
           "</div>"
          ],
          "text/plain": [
           "   alcohol_content  bitterness  darkness  fruitiness  is_yummy\n",
           "0         3.739295    0.422503  0.989463    0.215791         0\n",
           "1         4.207849    0.841668  0.928626    0.380420         0\n",
           "2         4.709494    0.322037  5.374682    0.145231         1\n",
           "3         4.684743    0.434315  4.072805    0.191321         1\n",
           "4         4.148710    0.570586  1.461568    0.260218         0"
          ]
         },
    
         "execution_count": 10,
    
    schmittu's avatar
    schmittu committed
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
    
        "# show first 5 rows\n",
        "beer_data.head(5)\n",
    
    schmittu's avatar
    schmittu committed
        "\n",
    
        "# there is alos beer_data.tail(5) !"
    
    schmittu's avatar
    schmittu committed
       ]
      },
      {
       "cell_type": "code",
    
       "execution_count": 11,
    
       "metadata": {},
       "outputs": [
        {
         "data": {
          "text/html": [
           "<div>\n",
           "<style scoped>\n",
           "    .dataframe tbody tr th:only-of-type {\n",
           "        vertical-align: middle;\n",
           "    }\n",
           "\n",
           "    .dataframe tbody tr th {\n",
           "        vertical-align: top;\n",
           "    }\n",
           "\n",
           "    .dataframe thead th {\n",
           "        text-align: right;\n",
           "    }\n",
           "</style>\n",
           "<table border=\"1\" class=\"dataframe\">\n",
           "  <thead>\n",
           "    <tr style=\"text-align: right;\">\n",
           "      <th></th>\n",
           "      <th>alcohol_content</th>\n",
           "      <th>bitterness</th>\n",
           "      <th>darkness</th>\n",
           "      <th>fruitiness</th>\n",
           "      <th>is_yummy</th>\n",
           "    </tr>\n",
           "  </thead>\n",
           "  <tbody>\n",
           "    <tr>\n",
           "      <th>count</th>\n",
           "      <td>225.000000</td>\n",
           "      <td>225.000000</td>\n",
           "      <td>225.000000</td>\n",
           "      <td>225.000000</td>\n",
           "      <td>225.000000</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>mean</th>\n",
           "      <td>4.711873</td>\n",
           "      <td>0.463945</td>\n",
           "      <td>2.574963</td>\n",
           "      <td>0.223111</td>\n",
           "      <td>0.528889</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>std</th>\n",
           "      <td>0.437040</td>\n",
           "      <td>0.227366</td>\n",
           "      <td>1.725916</td>\n",
           "      <td>0.117272</td>\n",
           "      <td>0.500278</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>min</th>\n",
           "      <td>3.073993</td>\n",
           "      <td>0.000000</td>\n",
           "      <td>0.000000</td>\n",
           "      <td>0.000000</td>\n",
           "      <td>0.000000</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>25%</th>\n",
           "      <td>4.429183</td>\n",
           "      <td>0.281291</td>\n",
           "      <td>1.197640</td>\n",
           "      <td>0.135783</td>\n",
           "      <td>0.000000</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>50%</th>\n",
           "      <td>4.740846</td>\n",
           "      <td>0.488249</td>\n",
           "      <td>2.026548</td>\n",
           "      <td>0.242396</td>\n",
           "      <td>1.000000</td>\n",
           "    </tr>\n",
           "    <tr>\n",
           "      <th>75%</th>\n",