{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import ch10util\n",
    "import dautil as dl\n",
    "from sklearn import metrics\n",
    "from IPython.display import HTML"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "context = dl.nb.Context('mae_rss')\n",
    "lr = dl.nb.LatexRenderer(chapter=10, start=11, context=context)\n",
    "lr.render(r'\\mathrm{MeanAE} = \\frac{1}{n}\\sum_{i=1}^n \\left| f_i-y_i\\right| =\\frac{1}{n}\\sum_{i=1}^n \\left| e_i \\right|')\n",
    "lr.render(r'RSS = \\sum_{i=1}^n (y_i - f(x_i))^2')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "dl.options.mimic_seaborn()\n",
    "dl.nb.RcWidget(context)\n",
    "dl.nb.LabelWidget(3, 2, context)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "sp = dl.plotting.Subplotter(3, 2, context)\n",
    "ch10util.plot_bootstrap('boosting',\n",
    "                        metrics.mean_absolute_error, sp.ax)\n",
    "sp.label()\n",
    "\n",
    "ch10util.plot_bootstrap('boosting',\n",
    "                        dl.stats.rss, sp.next_ax())\n",
    "sp.label()\n",
    "\n",
    "ch10util.plot_bootstrap('etr',\n",
    "                        metrics.mean_absolute_error, sp.next_ax())\n",
    "sp.label()\n",
    "\n",
    "ch10util.plot_bootstrap('etr',\n",
    "                        dl.stats.rss, sp.next_ax())\n",
    "sp.label()\n",
    "\n",
    "ch10util.plot_bootstrap('ransac',\n",
    "                        metrics.mean_absolute_error, sp.next_ax())\n",
    "sp.label()\n",
    "\n",
    "ch10util.plot_bootstrap('ransac',\n",
    "                        dl.stats.rss, sp.next_ax())\n",
    "sp.label()\n",
    "sp.fig.text(0, 1, ch10util.regressors())\n",
    "HTML(sp.exit())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "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
}
