File Exchange

image thumbnail

Boosting Demo

version (13.6 KB) by Richard Stapenhurst
A demo to illustrate the behaviour of Adaboost with various base learners on a few toy datasets.


Updated 02 Nov 2010

View License

This demo gives a clear visual presentation of what happens during the Adaboost algorithms. It shows how the decision boundary, example weights, training error and base learner weights change during training.

A selection of base learning algorithms are included: Linear Regression, Naive Bayes, Decision Stump, CART (requires stats toolbox), Neural Network (requires netlab) and SVM (requires libsvm). There are also 3 dataset generators (2-gaussians, circle and rotated checkerboard). There is documentation to assist with adding custom base learner algorithms or dataset generators.
The demo allows the choice of base learner and dataset. It is then possible to add one base learner at a time, according to the Adaboost algorithm.

After any number of base learners, the decision boundary and margins are shown on the plot. It is also possible to view two graphs: Error rates (showing how Adaboost affects training and generalisation errors as more base learners are added), and margin distributions (showing the cumulative distribution of margins for the current ensemble).

Base learners appear in a list at the left of the window. These include a checkbox which disables/enables each learner, and a scroll bar that adjusts its weight. This makes it possible to see the consequences of changing the weights assigned by Adaboost.

The Reset button enables all the base learners and sets their weights according to Adaboost. The checkboxes can be right-clicked to disable all other learners and view the impact of only the selected base learner.

Cite As

Richard Stapenhurst (2021). Boosting Demo (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (8)

Mohammad Amirian

I am running the code but no points are shown! It seems the points are invisible! Is there anyone who has the same problem? what should I do?!


it is a little difficult for me to understand it. and apply it.

xu rui

Antonio Fortes

Antonio Fortes

With 2014b and the much better graphics package, one must change the listeners. For example:

listener = handle.listener(a.learner_scroll,'ActionEvent',@(varargin)a.scroll_learners());
Will result in an error and must be replaced with:
listener = addlistener(a.learner_scroll,'Action',@(varargin)a.scroll_learners());

li kunming

How can I run it.Who can tell me.Thank you.


I find this code very inetrsting,I want to add an other data with inputs is a matrix(n,m) with n>2 and the output is a vector(1,m). But I find error of size of matrix

Alexander Patrushev

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!