Skip to content
Snippets Groups Projects
07_regression.ipynb 1.51 MiB
Newer Older
{
 "cells": [
  {
   "cell_type": "code",
schmittu's avatar
schmittu committed
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
schmittu's avatar
schmittu committed
       "\n",
       "    @import url('http://fonts.googleapis.com/css?family=Source+Code+Pro');\n",
schmittu's avatar
schmittu committed
       "\n",
       "    @import url('http://fonts.googleapis.com/css?family=Kameron');\n",
       "    @import url('http://fonts.googleapis.com/css?family=Crimson+Text');\n",
schmittu's avatar
schmittu committed
       "\n",
       "    @import url('http://fonts.googleapis.com/css?family=Lato');\n",
       "    @import url('http://fonts.googleapis.com/css?family=Source+Sans+Pro');\n",
       "\n",
schmittu's avatar
schmittu committed
       "    @import url('http://fonts.googleapis.com/css?family=Lora');\n",
       "\n",
       "\n",
       "    body {\n",
       "        font-family: 'Lora', Consolas, sans-serif;\n",
schmittu's avatar
schmittu committed
       "\n",
       "        -webkit-print-color-adjust: exact important !;\n",
schmittu's avatar
schmittu committed
       "\n",
       "\n",
       "\n",
schmittu's avatar
schmittu committed
       "\n",
       "    .alert-block {\n",
       "        width: 95%;\n",
       "        margin: auto;\n",
       "    }\n",
schmittu's avatar
schmittu committed
       "\n",
       "    .rendered_html code\n",
       "    {\n",
       "        color: black;\n",
       "        background: #eaf0ff;\n",
schmittu's avatar
schmittu committed
       "        background: #f5f5f5;\n",
       "        padding: 1pt;\n",
       "        font-family:  'Source Code Pro', Consolas, monocco, monospace;\n",
       "    }\n",
schmittu's avatar
schmittu committed
       "\n",
       "    p {\n",
       "      line-height: 140%;\n",
       "    }\n",
schmittu's avatar
schmittu committed
       "\n",
       "    strong code {\n",
       "        background: red;\n",
       "    }\n",
schmittu's avatar
schmittu committed
       "\n",
       "    .rendered_html strong code\n",
       "    {\n",
       "        background: #f5f5f5;\n",
       "    }\n",
schmittu's avatar
schmittu committed
       "\n",
       "    .CodeMirror pre {\n",
       "    font-family: 'Source Code Pro', monocco, Consolas, monocco, monospace;\n",
       "    }\n",
schmittu's avatar
schmittu committed
       "\n",
       "    .cm-s-ipython span.cm-keyword {\n",
       "        font-weight: normal;\n",
       "     }\n",
schmittu's avatar
schmittu committed
       "\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",
schmittu's avatar
schmittu committed
       "\n",
       "\n",
       "    div #notebook {\n",
schmittu's avatar
schmittu committed
       "        # font-size: 10pt;\n",
       "        line-height: 145%;\n",
       "        }\n",
schmittu's avatar
schmittu committed
       "\n",
       "    li {\n",
       "        line-height: 145%;\n",
       "    }\n",
       "\n",
       "    div.output_area pre {\n",
       "        background: #fff9d8 !important;\n",
       "        padding: 5pt;\n",
schmittu's avatar
schmittu committed
       "\n",
       "       -webkit-print-color-adjust: exact;\n",
       "\n",
schmittu's avatar
schmittu committed
       "\n",
       "\n",
       "\n",
       "    h1, h2, h3, h4 {\n",
       "        font-family: Kameron, arial;\n",
       "\n",
       "    }\n",
schmittu's avatar
schmittu committed
       "\n",
       "    div#maintoolbar {display: none !important;}\n",
schmittu's avatar
schmittu committed
       "    /*\n",
       "\n",
schmittu's avatar
schmittu committed
       "    div#site {\n",
       "        border-top: 20px solid #1F407A;\n",
       "        border-right: 20px solid #1F407A;\n",
schmittu's avatar
schmittu committed
       "        margin-bottom: 0;\n",
       "        padding-bottom: 0;\n",
       "    }\n",
schmittu's avatar
schmittu committed
       "    div#toc-wrapper {\n",
       "        border-left: 20px solid #1F407A;\n",
       "        border-top: 20px solid #1F407A;\n",
schmittu's avatar
schmittu committed
       "\n",
       "    }\n",
       "\n",
       "    body {\n",
       "        margin-botton:10px;\n",
       "    }\n",
       "    */\n",
       "\n",
schmittu's avatar
schmittu committed
       "</style>\n",
       "    <script>\n",
       "IPython.OutputArea.prototype._should_scroll = function(lines) {\n",
       "        return false;\n",
       "}\n",
schmittu's avatar
schmittu committed
       "    </script>\n",
       "\n",
       "\n",
       "<footer id=\"attribution\" style=\"float:left; color:#1F407A; background:#fff; font-family: helvetica;\">\n",
schmittu's avatar
schmittu committed
       "    Copyright (C) 2019-2021 Scientific IT Services of ETH Zurich,\n",
schmittu's avatar
schmittu committed
       "    <p>\n",
       "    Contributing Authors:\n",
       "    Dr. Tarun Chadha,\n",
       "    Dr. Franziska Oschmann,\n",
       "    Dr. Mikolaj Rybinski,\n",
       "    Dr. Uwe Schmitt.\n",
       "    </p<\n",
       "</footer>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
schmittu's avatar
schmittu committed
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
schmittu's avatar
schmittu committed
    "# IGNORE THIS CELL WHICH CUSTOMIZES LAYOUT AND STYLING OF THE NOTEBOOK !\n",
    "%matplotlib inline\n",
    "%config InlineBackend.figure_format = 'retina'\n",
    "import warnings\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "warnings.filterwarnings(\"ignore\", category=FutureWarning)\n",
    "warnings.filterwarnings(\"ignore\", category=DeprecationWarning)\n",
schmittu's avatar
schmittu committed
    "warnings.filterwarnings = lambda *a, **kw: None\n",
    "from IPython.core.display import HTML\n",
    "\n",
    "HTML(open(\"custom.html\", \"r\").read())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 7: Regression\n",
    "\n",
schmittu's avatar
schmittu committed
    "Regression belongs like classification to the field of supervised learning. \n",
    "\n",
    "<div class=\"alert alert-block alert-warning\">\n",
schmittu's avatar
schmittu committed
    "<i class=\"fa fa-info-circle\"></i>&nbsp; \n",
    "<strong>Regression predicts numerical values</strong> \n",
    "in contrast to classification which predicts categories.\n",
    "</div>\n",
    "\n",
    "<img src=\"./images/30416v.jpg\" title=\"made at imgflip.com\" width=35%/>\n",
schmittu's avatar
schmittu committed
    "\n",
schmittu's avatar
schmittu committed
    "<div class=\"alert alert-block alert-warning\">\n",
    "<i class=\"fa fa-info-circle\"></i>&nbsp; \n",
schmittu's avatar
schmittu committed
    "    Other main differences are:\n",
schmittu's avatar
schmittu committed
    "\n",
schmittu's avatar
schmittu committed
    "* Different quality measures\n",
schmittu's avatar
schmittu committed
    "* Other algorithms\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example: Salmon weight\n",
    "\n",
    "The dataset `data/salmon.csv` holds measurements of `circumference`, `length` and `weight` for  `atlantic` and `sockeye` salmons.\n",
    "\n",
    "Our goal is to predict `weight` based on the other three features."
Loading
Loading full blame...