marcotcr / lime

Lime: Explaining the predictions of any machine learning classifier
BSD 2-Clause "Simplified" License
11.4k stars 1.79k forks source link

top_label #703

Open ElineideSilva opened 1 year ago

ElineideSilva commented 1 year ago

The top_label is the number of classes?

My problem has 4 classes, even if I put a top_label=10 it always returns 4

paulbauriegel commented 1 year ago

From the source code:

yss = predict_fn(inverse)  # Array of probabilty per class
...
if top_labels:
    labels = np.argsort(yss[0])[-top_labels:]

Not quite, It limits the number of labels you get explainations for. Let's say you have 50 classes and you set it to 10 then you will get the 10 labels with the highest probability based on the prediction for the inverse values. If you have four classes on the other hand, but you set it to 10, it will only return 4, because there are no more labels in the list.