DistrictDataLabs / yellowbrick

Visual analysis and diagnostic tools to facilitate machine learning model selection.
http://www.scikit-yb.org/
Apache License 2.0
4.3k stars 559 forks source link

Updated importances.py to throw YellowbrickValueError when stack parameter is used incorrectly #1181

Closed pdamodaran closed 3 years ago

pdamodaran commented 3 years ago

This PR fixes #1179 which reported a bug that caused a problem to occur when users set stack=True in the FeatureImportances vizualizer for a model that does not return a coef_ array in the shape of (n_classes, n_features). While stack=True should not be used in these cases, the error the user saw was not informative and did not state what the real issue was.

I have made the following changes:

  1. Added a YellowbrickValue error to address these situations.
  2. Added a test to test_importances.py.
codecov-commenter commented 3 years ago

Codecov Report

Merging #1181 (7ba262e) into develop (783069e) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1181   +/-   ##
========================================
  Coverage    90.42%   90.42%           
========================================
  Files           90       90           
  Lines         5076     5078    +2     
========================================
+ Hits          4590     4592    +2     
  Misses         486      486           
Impacted Files Coverage Δ
yellowbrick/model_selection/importances.py 98.42% <100.00%> (+0.02%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 783069e...7ba262e. Read the comment docs.