... human learn: fallback


The diagram in the video can easily be constructed using a FunctionClassifier. 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.