Skip to content

Instantly share code, notes, and snippets.

View lorenzwalthert's full-sized avatar

Lorenz Walthert lorenzwalthert

View GitHub Profile
# adapted from https://towardsdatascience.com/simple-trick-to-train-an-ordinal-regression-with-any-classifier-6911183d2a3c
class OrdinalClassifier:
def __init__(self, clf):
self.clf = clf
self.clfs = {}
def fit(self, X, y):
self.classes_ = np.sort(np.unique(y))
if self.classes_.shape[0] > 2:
for level in self.classes_[: (self.classes_.shape[0] - 1)]: