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

Test `get_params` in all of our visualizers #1252

Open bbengfort opened 2 years ago

bbengfort commented 2 years ago

Describe the issue

In #1232 we discovered that printing out a Visualizer in a notebook with the KElbowVisualizer was failing because calls to get_params were failing with an attribute error. We also experienced this issue with the DroppingCurve visualizer. ModelVisualizers wrap estimator objects and the error messages from get_params -- AttributeError were confusing, so we updated the Wrapper class to return better error messages.

The fix for the KElbow visualizer was to ensure that all hyperparameters pass in __init__ were getting saved on the estimator because of sklearn's metaprogramming. The fix for DroppingCurve was different. However, to make sure that all our visualizer are working in the future, we should add a simple test_get_params for each visualizer as follows:

    def test_get_params(self):
        """
        Ensure dropping curve get params works correctly
        """
        oz = DroppingCurve(MultinomialNB())
        params = oz.get_params()
        assert len(params) > 0