Adaptive Boosting (AdaBoost) Classification: MATLAB, R and Python codes– All you have to do is just preparing data set (very simple, easy and practical)

DataAnalysis For Beginner
3 min readSep 9, 2016

--

I release MATLAB, R and Python codes of Adaptive Boosting (AdaBoost) Classification (ABC). They are very easy to use. You prepare data set, and just run the code! Then, ABC and prediction results for new samples can be obtained. Very simple and easy!

You can buy each code from the URLs below.

MATLAB

https://gum.co/RYGs
Please download the supplemental zip file (this is free) from the URL below to run the ABC code.
http://univprofblog.html.xdomain.jp/code/MATLAB_scripts_functions.zip

R

https://gum.co/ovUWC
Please download the supplemental zip file (this is free) from the URL below to run the ABC code.
http://univprofblog.html.xdomain.jp/code/R_scripts_functions.zip

Python

https://gum.co/igWUi
Please download the supplemental zip file (this is free) from the URL below to run the ABC code.
http://univprofblog.html.xdomain.jp/code/supportingfunctions.zip

Procedure of ABC in the MATLAB, R and Python codes

To perform appropriate ABC, the MATLAB, R and Python codes follow the procedure below, after data set is loaded.

1. Decide classification method
Decision tree is used basically. Since AdaBoost is ensemble method, performance of classifiers is not important.

2. Decide the number of classification models

3. Autoscale explanatory variable (X) (if necessary)
Autoscaling means centering and scaling. Mean of each variable becomes zero by subtracting mean of each variable from the variable in centering. Standard deviation of each variable becomes one by dividing standard deviation of each variable from the variable in scaling.

4. Construct AdaBoost model

5. Calculate confusion matrix between actual Y and calculated Y
Accuracy rate, detection rate, precision and so on can be calculated from each confusion matrix, if necessary.

6. In prediction, subtract the mean in the autoscalling of X in 1. from X-variables, and then, divide X-variables by the standard deviation in the autoscalling of X in 1., for new samples, if X is autoscaled in 3.

7. Estimate Y and calculate possibility of each class for new samples, based on AdaBoost model in 4.

How to perform ABC?

1. Buy the code and unzip the file

MATLAB: https://gum.co/RYGs

R: https://gum.co/ovUWC

Python: https://gum.co/igWUi

2. Download and unzip the supplemental zip file (this is free)

MATLAB: http://univprofblog.html.xdomain.jp/code/MATLAB_scripts_functions.zip

R: http://univprofblog.html.xdomain.jp/code/R_scripts_functions.zip

Python: http://univprofblog.html.xdomain.jp/code/supportingfunctions.zip

3. Place the supplemental files at the same directory or folder as that of the ABC code.

4. Prepare data set. For data format, see the article below.

https://medium.com/@univprofblog1/data-format-for-matlab-r-and-python-codes-of-data-analysis-and-sample-data-set-9b0f845b565a#.3ibrphs4h

5. Run the code!

Estimated values of Y for “data_prediction2.csv” are saved in ”PredictedY2.csv”. The probability of each class for each estimated value is saved in “PredictedY2_Probability.csv”.

Required settings

Please see the article below.
https://medium.com/@univprofblog1/settings-for-running-my-matlab-r-and-python-codes-136b9e5637a1#.paer8scqy

Examples of execution results

--

--

DataAnalysis For Beginner

I am a data scientist in Japan, and will share my knowledge and programming codes about data analysis with you. The codes are written in R, Python and MATLAB.