ArticleslgStudy

computer science

Gradient boosting

Gradient boosting is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Gradient boosting rather than just read about it. In short: Gradient boosting is a machine learning technique based on boosting in a functional space, where the target is pseudo-residuals instead of residuals as in traditional boosting. It gives a prediction model in the form of an ensemble of weak prediction models, i.e., models that make very few assumptions about the data, which are typically simple decision trees.

Key takeaways

  • Gradient boosting belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Gradient boosting to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Gradient boosting from memory before moving on to harder problems.

Reference excerpt

Gradient boosting is a machine learning technique based on boosting in a functional space, where the target is pseudo-residuals instead of residuals as in traditional boosting. It gives a prediction model in the form of an ensemble of weak prediction models, i.e., models that make very few assumptions about the data, which are typically simple decision trees. When a decision tree is the weak learner, the resulting algorithm is called gradient-boosted trees; it usually outperforms random forest. As with other boosting methods, a gradient-boosted trees model is built in stages, but it generalizes the other methods by allowing optimization of an arbitrary differentiable loss function.

History The idea of gradient boosting originated in the observation by Leo Breiman that boosting can be interpreted as an optimization algorithm on a suitable cost function. Explicit regression gradient boosting algorithms were subsequently developed, by Jerome H. Friedman, (in 1999 and later in 2001) simultaneously with the more general functional gradient boosting perspective of Llew Mason, Jonathan Baxter, Peter Bartlett and Marcus Frean. The latter two papers introduced the view of boosting algorithms as iterative functional gradient descent algorithms. That is, algorithms that optimize a cost function over function space by iteratively choosing a function (weak hypothesis) that points in the negative gradient direction. This functional gradient view of boosting has led to the development of boosting algorithms in many areas of machine learning and statistics beyond regression and classification.

Informal introduction (This section follows the exposition by Cheng Li.) Like other boosting methods, gradient boosting combines weak "learners" into a single strong learner iteratively. It is easiest to explain in the least-squares regression setting, where the goal is to teach a model F to predict values of the form ŷ=F(x) by minimizing the mean squared error 1n∑i(ŷi−yi)2, where i indexes over some training set of size n of actual values of the output variable y:

ŷi= the predicted value F(xi) yi= the observed value n= the size of the sample, i.e. the number of observations in y If the algorithm has M stages, at each stage m (1≤m≤M), suppose some imperfect model Fm (for low m, this model may simply predict ŷi to be y¯, the mean of y). In order to improve Fm, our algorithm should add some new estimator, hm(x). Thus,

Fm+1(xi)=Fm(xi)+hm(xi)=yi or, equivalently,

hm(xi)=yi−Fm(xi). Therefore, gradient boosting will fit hm to the residual yi−Fm(xi). As in other boosting variants, each Fm+1 attempts to correct the errors of its predecessor Fm. A generalization of this idea to loss functions other than squared error, and to classification and ranking problems, follows from the observation that residuals hm(xi) for a given model are proportional to the negative gradients of the mean squared error (MSE) loss function (with respect to F(xi)):

LMSE=1n∑i=1n(yi−F(xi))2 −∂LMSE∂F(xi)=2n(yi−F(xi))=2nhm(xi). So, gradient boosting could be generalized to a gradient descent algorithm by plugging in a different loss and its gradient.

Algorithm Many supervised learning problems involve an output variable y and a vector of input variables x, related to each other with some probabilistic distribution. The goal is to find some function F̂(x) that best approximates the output variable from the values of input variables. This is formalized by introducing some loss function L(y,F(x)) and minimizing it in expectation:

F̂=argminF𝔼x,y[L(y,F(x))]. The gradient boosting method assumes a real-valued y. It seeks an approximation F̂(x) in the form of a weighted sum of M functions hm(x) from some class ℋ, called base (or weak) learners:

F̂(x)=∑m=1Mγmhm(x)+const, where γm is the weight at stage m. We are usually given a training set {(x1,y1),…,(xn,yn)} of known values of x and corresponding values of y. In accordance with the empirical risk minimization principle, the method tries to find an approximation F̂(x) that minimizes the average value of the loss function on the training set, i.e., minimizes the empirical risk. It does so by starting with a model, consisting of a constant function F0(x), and incrementally expands it in a greedy fashion:

F0(x)=arg⁡minh0∈ℋ∑i=1nL(yi,h0(xi)), Fm(x)=Fm−1(x)+(argminhm∈ℋ[∑i=1nL(yi,Fm−1(xi)+hm(xi))])(x), for m≥1, where hm∈ℋ is a base learner function. Unfortunately, choosing the best function hm at each step for an arbitrary loss function L is a computationally infeasible optimization problem in general. Therefore, we restrict our approach to a simplified version of the problem. The idea is to apply a steepest descent step to this minimization problem (functional gradient descent). The basic idea is to find a local minimum of the loss function by iterating on Fm−1(x). In fact, the local maximum-descent direction of the loss function is the negative gradient. Hence, moving a small amount γ such that the linear approximation remains valid:

Fm(x)=Fm−1(x)−γ∑i=1n∇Fm−1L(yi,Fm−1(xi)) where γ>0. For small γ, this implies that L(yi,Fm(xi))≤L(yi,Fm−1(xi)).

Furthermore, we can optimize γ by finding the γ value for which the loss function has a minimum:

γm=argminγ∑i=1nL(yi,Fm(xi))=arg⁡minγ∑i=1nL(yi,Fm−1(xi)−γ∇Fm−1L(yi,Fm−1(xi))). If we considered the continuous case, i.e., where ℋ is the set of arbitrary differentiable functions on ℝ, we would update the model in accordance with the following equations

Fm(x)=Fm−1(x)−γm∑i=1n∇Fm−1L(yi,Fm−1(xi)) where γm is the step length, defined as γm=arg⁡minγ∑i=1nL(yi,Fm−1(xi)−γ∇Fm−1L(yi,Fm−1(xi))). In the discrete case however, i.e. when the set ℋ is finite, we choose the candidate function h closest to the gradient of L for which the coefficient γ may then be calculated with the aid of line search on the above equations. Note that this approach is a heuristic and therefore doesn't yield an exact solution to the given problem, but rather an approximation. In pseudocode, the generic gradient boosting method is:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Gradient boosting

Start with the simplest possible case. Write down what Gradient boosting claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Gradient boosting before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Gradient boosting ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Gradient boosting

In research
Gradient boosting appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Gradient boosting in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Gradient boosting is common in secondary-school and first-year university syllabi. It links to neighbouring topics Classification algorithms, Decision trees, Ensemble learning, so understanding it makes those chapters shorter.
In everyday life
Look for Gradient boosting outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Gradient boosting” →

How to study Gradient boosting in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Gradient boosting means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Gradient boosting out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Gradient boosting in simple terms?

Gradient boosting is a machine learning technique based on boosting in a functional space, where the target is pseudo-residuals instead of residuals as in traditional boosting. It gives a prediction model in the form of an ensemble of weak prediction models, i.e., models that make very few assumpti…

Why does Gradient boosting matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Gradient boosting?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Gradient boosting.

Tags

  • Classification algorithms
  • Decision trees
  • Ensemble learning

Keep exploring