interpretml / interpret

Fit interpretable models. Explain blackbox machine learning.
https://interpret.ml/docs
MIT License
6.04k stars 715 forks source link

MAINT: simplify term_importances #503

Closed DerWeh closed 3 months ago

DerWeh commented 3 months ago

I found the function term_importances unnecessarily complicated. Within the loop, there are 3 branches. To my mind, the function is more understandable if we simply pull out the if clauses.

This handles the pathological case of having only a single class for importance_type="min_max" by an early return.

I dropped the use of itemset, as its use is discouraged in the documentation. It makes the code harder to read, and I cannot imagine a case where its performance matters.

paulbkoch commented 3 months ago

Thanks @DerWeh -- Nice rewrite! Looks a lot cleaner now.