Code covered by the BSD License  

Highlights from
Classic AdaBoost Classifier

4.8

4.8 | 5 ratings Rate this file 231 Downloads (last 30 days) File Size: 4.07 KB File ID: #27813
image thumbnail

Classic AdaBoost Classifier

by Dirk-Jan Kroon

 

01 Jun 2010 (Updated 20 Jan 2012)

Weak threshold classifier boosted to strong Classifier with Adaboost

| Watch this File

File Information
Description

This a classic AdaBoost implementation, in one single file with easy understandable code.

The function consist of two parts a simple weak classifier and a boosting part:
The weak classifier tries to find the best threshold in one of the data dimensions to separate the data into two classes -1 and 1
The boosting part calls the classifier iteratively, after every classification step it changes the weights of miss-classified examples. This creates a cascade of "weak classifiers" which behaves like a "strong classifier"
.
Training mode:
  [estimateclass,model]=adaboost('train',datafeatures,dataclass,itt)
Apply mode:
 estimateclass=adaboost('apply',datafeatures,model)
 
inputs/outputs:
   datafeatures : An Array with size number_samples x number_features
   dataclass : An array with the class off all examples, the class
                 can be -1 or 1
   itt : The number of training iterations
   model : A struct with the cascade of weak-classifiers
   estimateclass : The by the adaboost model classified data
            
.
Please leave a comment, if you like the code, find a bug or have a suggestion.

MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
26 Sep 2010 Ruchir Srivastava

Hi Dirk-Jan Kroon,

Thank you for the nice comments making the code easily understandable.

Can I do feature selection using your code? I am new at Adaboost so am not able to figure out how can this be done. Can you please help me?

09 Oct 2010 David

Xu Cui code?

23 Nov 2010 h gd

Easy to understand

17 Jan 2011 AMVR

Great contribution, Dirk-Jan.

This is just a suggestion, but have you thought about adding probability calibration to the output of the classifier? e.g. logistic correction, platt scaling or isotonic regression (see "Obtaining Calibrated Probabilities from Boosting", by Alexandru Niculescu-Mizil and Rich Caruana for more context).

13 Mar 2011 CarloG  
22 Mar 2011 sudheesh p

i am not able to run the adaboost m-file, it shows some eeror at the statement switch (mode)asking about error at mode and in the example m-file only the training pattern is visible

10 Jul 2011 jinkyu do  
02 Dec 2011 Su Dongcai

Neatly codes, very nice demonstration

10 Dec 2011 Muhammad Hamid

Hi!
Can i use this code instead of Haar feature based AdaBoost cascade classifiers?
Actually i am not understanding the concept behind Adaboost and its very much compulsory for me to implement it in just 10 days.If i have to use the Adaboost cascade classifiers on the basis of the brake lights and taillights of the vehicles on the roads in evening hours then what will be parameters of this function?waiting for reply...please help

16 Feb 2012 Andreas

Hi Dirk,
Are there any requirements on the features (such as no NaNs? numerical scaling? equal numbers in each class?). The internal variable p2c at line 117 has runs of large and NaN values, causing accumarray and the WeightedThresholdClassifier function to crash. Thanks - Andreas

Please login to add a comment or rating.
Updates
01 Jun 2010

Changed Screenshot and example figure

30 Aug 2010

Solved division by zero, causing NaN

29 Dec 2010

Changed bug : ndims(datafeatures)to size(datafeatures,2)

07 Oct 2011

Speed improvement (Replaced loops by 1D indexing and bsxfun operations.)
The function now limits features of the test data to the outer-boundaries of training data.

20 Jan 2012

Fixed boundary bug

Tag Activity for this File
Tag Applied By Date/Time
adaboost Dirk-Jan Kroon 01 Jun 2010 10:43:53
boosting Dirk-Jan Kroon 01 Jun 2010 10:43:53
classifier Dirk-Jan Kroon 01 Jun 2010 10:43:53
classification Dirk-Jan Kroon 01 Jun 2010 10:43:53
freund Dirk-Jan Kroon 01 Jun 2010 10:43:53
schapire Dirk-Jan Kroon 01 Jun 2010 10:43:53
treshold Dirk-Jan Kroon 01 Jun 2010 10:43:53
strong classifier Dirk-Jan Kroon 01 Jun 2010 10:43:53
weak classifier Dirk-Jan Kroon 01 Jun 2010 10:43:53
threshold Dirk-Jan Kroon 30 Aug 2010 12:55:56
cascade Dirk-Jan Kroon 30 Aug 2010 12:55:56
adaboost ruchismita parida 20 Apr 2011 09:39:43
boosting jp 12 Jun 2011 02:30:25
adaboost ????????? 07 Aug 2011 15:56:52
classification B.K. Mishra 17 Aug 2011 04:59:11

Contact us at files@mathworks.com