human learn: fallback
Human-Learn contains scikit-learn compatible tools that should make it easier to construct and benchmark rule based systems that are designed by humans. You can also use it in combination with ML models. In this series of videos we'll demonstrate some of the features.
The diagram in the video can easily be constructed using a
pseudo-code implementation is listed below.
import numpy as np from hulearn.classification import FunctionClassifier # These two models are assumed to be trained beforehand. outlier = WhatEverOutlierDetector().fit(X, y) classifier = WhatEverClassifier().fit(X, y) def make_decision(dataf, proba_threshold=0.8): # First we create a resulting array with all the predictions res = classifier.predict(dataf) # If we detect doubt, "classify" it as a fallback instead. proba = classifier.predict_proba(dataf) res = np.where(proba.max(axis=1) < proba_threshold, "doubt_fallback", res) # If we detect an outlier, we'll fallback too. res = np.where(outlier.predict(dataf) == -1, "outlier_fallback", res) # This `res` array contains the output of the drawn diagram. return res fallback_model = FunctionClassifier(make_decision, proba_threshold=0.8)
Feedback? See an issue? Something unclear? Feel free to mention it here.
If you want to be kept up to date, consider signing up for the newsletter.