# Cost Sensitive Boosting Algorithms: Do we really need them?¶

AdaBoost is a successful and popular classification method, but it is not geared towards solving cost-sensitive classification problems, i.e. problems where the costs of different types of erroneous predictions are unequal. In our 2016 paper cited below, we reviewed all cost-sensitive variants of AdaBoost in the literature, along with our own adaptations. Below we provide code for the method that achieves the best empirical results without any need for parameter tuning, while satisfying all desirable theoretical properties. The method, 'Calibrated AdaMEC', is described in detail and motivated in the paper:

Cost-sensitive boosting algorithms: Do we really need them?
Nikolaos Nikolaou, Narayanan U. Edakunni, Meelis Kull, Peter A. Flach, Gavin Brown
Machine Learning, 104(2), pages 359-384, 2016

Please, direct any questions or feedback to Nikolaos Nikolaou or Gavin Brown.

### Running the code¶

The following code shows an example of how to use Calibrated AdaMEC. Do not let the name intimidate you; this is just AdaBoost that properly calibrates its probability estimates and uses a cost-sensitive decision threshold to classify new data. The code showcases how to train and generate scores and predictions under Calibrated AdaMEC. The syntax follows the conventions of the AdaBoost implementation of scikit-learn.

In [ ]:

#The code below assumes the user already split the binary classification data (classes denoted 0,1)
#into training and test sets, that they defined the cost of a false positive C_FP & the cost of a
#false negative C_FN and selected the weak learner base_estimator and the ensemble size n_estimators

#Create and train a CalibratedAdaMECClassifier --being cost-sensitive, it takes C_FP & C_FN as arguments

#Produce AdaBoost & Calibrated AdaMEC scores (probability estimates) - keep only positive class scores

### Comparing the two methods¶

You can evaluate the two algorithms in terms of probability estimation using the Brier score, or the log-loss, found e.g. in the $metrics$ module of scikit-learn.

In [ ]:
from sklearn import metrics

You will see that Calibrated AdaMEC achieves lower scores for both (better probability estimation).

You can evaluate the cost-sensitive behaviour of the classifications produced by the two algorithms in terms of total cost sensitive loss (empirical risk):

In [ ]:
from sklearn import metrics

Pos = sum(y_train[np.where(y_train == 1)]) #Number of positive training examples
Neg = len(y_train) - Pos                   #Number of negative training examples
skew = C_FP*Neg / (C_FN*Pos + C_FP*Neg)    #Skew (combined asymmetry due to both cost and class imbalance)