Search code examples
javawekaadaboost

Obtain instance weights from AdaBoostM1 in Weka


AdaBoostM1 is a boosting algorithm implemented in Weka. A key component of this algorithm is the reweighting of "hard to classify" instances after each iteration. I want to obtain the weight of each instance that AdaBoostM1 uses for each classifier it constructs

I have used "Instance.weight()" to obtain instance weights before and after building an AdaBoostM1 model. The weights do not change and are therefore not what I am interested in. The source code for AdaBoostM1 is available and it can be seen that weights are set during the construction of a model (here). Can the instance weights somehow be obtained before AdaBoostM1 builds each new model?


Solution

  • No, Weka's AdaboostM1 does not have such feature. But you could inherit the AdaBoostM1 class, copy the AdaBoostM1#buildClassifierUsingResampling method from the source, and paste it in your subclass and manipulate the double[] weights variable (as seen in line 513).