Bagging with adaptive costs