learning.ipynb 394 ko
Newer Older
Pranjal Aswani's avatar
Pranjal Aswani a validé
       "0"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "iris2 = DataSet(name=\"iris\")\n",
    "iris2.classes_to_numbers()\n",
    "\n",
    "adaboost = AdaboostLearner(iris2)\n",
    "\n",
    "adaboost([5, 3, 1, 0.1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "That is the correct answer. Let's check the error rate of adaboost with perceptron."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error ratio for adaboost:  0.046666666666666634\n"
     ]
    }
   ],
   "source": [
    "print(\"Error ratio for adaboost: \", err_ratio(adaboost, iris2))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "It reduced the error rate considerably. Unlike the `PerceptronLearner`, `AdaBoost` was able to learn the complexity in the iris dataset."
   ]
  }
 ],
 "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",
 "nbformat_minor": 2