{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "4cb317e4-3aa3-4ec7-ad50-83fbaad4dd73",
"metadata": {
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"# Install the necessary dependencies\n",
"\n",
"import os\n",
"import sys\n",
"!{sys.executable} -m pip install --quiet pandas scikit-learn numpy matplotlib jupyterlab_myst ipython"
]
},
{
"cell_type": "markdown",
"id": "841ebd40",
"metadata": {
"tags": [
"remove-cell"
]
},
"source": [
"---\n",
"license:\n",
" code: MIT\n",
" content: CC-BY-4.0\n",
"github: https://github.com/ocademy-ai/machine-learning\n",
"venue: By Ocademy\n",
"open_access: true\n",
"bibliography:\n",
" - https://raw.githubusercontent.com/ocademy-ai/machine-learning/main/open-machine-learning-jupyter-book/references.bib\n",
"---"
]
},
{
"cell_type": "markdown",
"id": "0f3cbb4f",
"metadata": {},
"source": [
"# Gradient Boosting"
]
},
{
"cell_type": "markdown",
"id": "20873551",
"metadata": {},
"source": [
":::{figure} https://static-1300131294.cos.ap-shanghai.myqcloud.com/images/ml-advanced/gradient_boosting/Boosting.jpg\n",
"---\n",
"name: 'Boosting'\n",
"width: 90%\n",
"---\n",
"Boosting\n",
":::"
]
},
{
"cell_type": "markdown",
"id": "b37ef333",
"metadata": {},
"source": [
"Today we are going to have a look at one of the most popular and practical machine learning algorithms: gradient boosting. \n",
"\n",
"
\n", "\n", "A demo of Gradient Boosting. [source]\n", "
" ] }, { "cell_type": "markdown", "id": "a97c640f", "metadata": {}, "source": [ "## Introduction and history of boosting\n", "Almost everyone in machine learning has heard about gradient boosting. Many data scientists include this algorithm in their data scientist's toolbox because of the good results it yields on any given (unknown) problem. \n", "\n", "Furthermore, XGBoost is often the standard recipe for [winning](https://github.com/dmlc/xgboost/blob/master/demo/README.md#usecases) [ML competitions](http://blog.kaggle.com/tag/xgboost/). It is so popular that the idea of stacking XGBoosts has become a meme. Moreover, boosting is an important component in [many recommender systems](https://en.wikipedia.org/wiki/Learning_to_rank#Practical_usage_by_search_engines); sometimes, it is even considered a [brand](https://yandex.com/company/technologies/matrixnet/).\n", "Let's look at the history and development of boosting." ] }, { "cell_type": "markdown", "id": "432f24c4-79ee-4087-8f26-e7d53d854171", "metadata": {}, "source": [ "Boosting was born out of [the question:](http://www.cis.upenn.edu/~mkearns/papers/boostnote.pdf) is it possible to get one strong model from a large amount of relatively weak and simple models? \n", "By saying \"weak models\", we do not mean simple basic models like decision trees but models with poor accuracy performance, where poor is a little bit better than random.\n", "\n", "[A positive mathematical answer](http://www.cs.princeton.edu/~schapire/papers/strengthofweak.pdf) to this question was identified, but it took a few years to develop fully functioning algorithms based on this solution e.g. AdaBoost. These algoritms take a greedy approach: first, they build a linear combination of simple models (basic algorithms) by re-weighing the input data. Then, the model (usually a decision tree) is built on earlier incorrectly predicted objects, which are now given larger weights. \n", "\n", "