class CDEAC(object): def __init__(self, base_clf_class): self.base_clf_class = base_clf_class def fit(self, X_train, y_train): self.weight = GenericWeights(self.base_clf_class) ac = AC2(self.base_clf_class) ac.fit([X_train, y_train]) self.ac = ac self.X_train = X_train self.y_train = y_train def predict(self, X_test): class_dist = self.ac.predict_dict(X_test) self.weight.fit(self.X_train, self.y_train, class_dist) y_pred = self.weight.predict(X_test) return y_pred
class CDEITR(object): ''' Combination of EM based CDE and Cost sensitive learning based on class reweighting. ''' def __init__(self, base_clf_class): self.base_clf_class = base_clf_class def fit(self, X_train, y_train): self.weight = GenericWeights(self.base_clf_class) it = Itr2(self.base_clf_class) it.fit([X_train, y_train]) self.it = it self.X_train = X_train self.y_train = y_train def predict(self, X_test): class_dist = self.it.predict_dict(X_test) self.weight.fit(self.X_train, self.y_train, class_dist) y_pred = self.weight.predict(X_test) return y_pred