Skip to main content
. 2022 Jul 28;9(8):350. doi: 10.3390/bioengineering9080350
Algorithm 2: Cost-Sensitive AdaBoost
Input: training dataset S=x1,y1,,x2,y2,,xn,yn, base learner h, the number of iterations T.
Output: the final strong classifier H.
Procedure:
  • 1.

    for i=1:1:n

  • 2.

    compute the weight of the sample xi: D1i=1n

  • 3.

    end for

  • 4.

    for t=1:1:T

  • 5.

    select a training data subset X from S, fit h using X to get a weak classifier ht

  • 6.

    let n+ and n indicate the positive and negative classes, respectively. Compute the error rate εt of the base learner for both the positive class εtp and negative class εtn: εt=εtp+εtn2,  where

       εtp=Phtxiyi=i=1n+DtiΙhtxiyi and εtn=Phtxiyi=i=1nDtiΙhtxiyi

  • 7.

    compute the weight of ht: αt=12ln1εtεt

  • 8.

    update the weight of all the instances in S:

    for i=1:1:n

              Dt+1i=DtiZtexpαtβiyihtxi

    where Zt is a normalization factor and is calculated as: Zt=i=1nDtiexpαtβiyihtxi

    and βi is calculated as: βi=TPtFPt+TPtc10, if yi=1, htxi=1TNtFNt+TNtc01, if yi=1, htxi=1TPtFPt+TPtc11, if yi=1, htxi=1TNtFNt+TNtc00, if yi=1, htxi=1

    where TPt, TNt, FPt, FNt are true positive, true negative, false positive, and false negative values for iteration t. Meanwhile, c10, c01, c11, c00 are the cost-sensitive factors, where c10>c00 and c01>c11.

  • 9.

    end for

  • 10.

    end for

  • 11.

    the final classifier is obtained as follows: Hx=signt=1Tαthtx