Skip to content

Commit

Permalink
added docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
Garve committed Dec 13, 2021
1 parent e43fd9c commit 41de343
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions doubtlab/reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __call__(self, X, y):

@staticmethod
def from_proba(proba, n_classes, threshold=0.5):
"""Outputs a reason array from a prediction array, skipping the need for a model."""
entropies = -(proba * np.log(proba) / np.log(n_classes)).sum(axis=1)
return np.where(entropies > threshold, entropies, 0)

Expand Down

0 comments on commit 41de343

Please sign in to comment.