def fit(self, X, y):
    (X, y) = check_X_y(X, y)
    self.classes_ = unique_labels(y)
    self.y_ = y
    kbd = KBinsDiscretizer(n_bins=len(np.unique(y)), encode='ordinal')
    X = kbd.fit_transform(X)
    self.X_ = X
    self.kbd_ = kbd
    cm_list = []
    hits = []
    for i in X.T:
        cm = contingency_matrix(i, y)
        cm_list.append(cm)
        hits.append(sum((max(k) for k in cm)))
    rule = np.argmax(hits)
    self.r_ = rule
    rule_cm = cm_list[rule]
    class_selector = []
    for (i, c) in enumerate(rule_cm):
        cSum = sum(c)
        probRatio = [(i / cSum) for i in c]
        probRatio = list(accumulate(probRatio))
        class_selector.append(probRatio)
    self.class_selector = class_selector
    return self
def fit(self, X, y):
    (X, y) = check_X_y(X, y)
    self.classes_ = unique_labels(y)
    self.y_ = y
    kbd = KBinsDiscretizer(n_bins=len(np.unique(y)), encode='ordinal')
    X = kbd.fit_transform(X)
    self.X_ = X
    self.kbd_ = kbd
    cm_list = []
    hits = []
    for i in X.T:
        cm = contingency_matrix(i, y)
        cm_list.append(cm)
        hits.append(sum((max(k) for k in cm)))
    rule = np.argmax(hits)
    self.r_ = rule
    rule_cm = cm_list[rule]
    class_selector = []
    for (i, c) in enumerate(rule_cm):
        cSum = sum(c)
        probRatio = [(i / cSum) for i in c]
        probRatio = list(accumulate(probRatio))
        class_selector.append(probRatio)
    self.class_selector = class_selector
    return self