Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CooksDistance regressor generating error #1314

Open
ImolaS3 opened this issue May 10, 2024 · 0 comments
Open

CooksDistance regressor generating error #1314

ImolaS3 opened this issue May 10, 2024 · 0 comments

Comments

@ImolaS3
Copy link

ImolaS3 commented May 10, 2024

Describe the bug
I recieve the error: 'Axes.stem() got an unexpected keyword argument 'use_line_collection'

To Reproduce
import os
import pandas as pd
from yellowbrick.regressor import CooksDistance

df = pd.read_csv('Advertising.csv')

X = df[['TV', 'Radio', 'Newspaper']]
y = df['Sales']

visualizer = CooksDistance()

visualizer.fit(X, y)

visualizer.show(outpath="Cook's_Distance_Plot.png")

Dataset
Did you use a specific dataset to produce the bug? Where can we access it?

Expected behavior
The code should display the output of the CooksDistance regressor

Traceback

TypeError                                 Traceback (most recent call last)
Cell In[26], line 19
     16 # Creating the Cook's distance plot
     17 visualizer = CooksDistance()
---> 19 visualizer.fit(X, y)
     21 # Saving plot in PNG format
     22 visualizer.show(outpath="Cook's_Distance_Plot.png")

File ~/anaconda3/lib/python3.11/site-packages/yellowbrick/regressor/influence.py:173, in CooksDistance.fit(self, X, y)
    168 self.outlier_percentage_ = (
    169     sum(self.distance_ > self.influence_threshold_) / X.shape[0]
    170 )
    171 self.outlier_percentage_ *= 100.0
--> 173 self.draw()
    174 return self

File ~/anaconda3/lib/python3.11/site-packages/yellowbrick/regressor/influence.py:182, in CooksDistance.draw(self)
    177 """
    178 Draws a stem plot where each stem is the Cook's Distance of the instance at the
    179 index specified by the x axis. Optionaly draws a threshold line.
    180 """
    181 # Draw a stem plot with the influence for each instance
--> 182 _, _, baseline = self.ax.stem(
    183     self.distance_, linefmt=self.linefmt, markerfmt=self.markerfmt,
    184     use_line_collection=True
    185 )
    187 # No padding on either side of the instance index
    188 self.ax.set_xlim(0, len(self.distance_))

File ~/anaconda3/lib/python3.11/site-packages/matplotlib/__init__.py:1465, in _preprocess_data.<locals>.inner(ax, data, *args, **kwargs)
   1462 @functools.wraps(func)
   1463 def inner(ax, *args, data=None, **kwargs):
   1464     if data is None:
-> 1465         return func(ax, *map(sanitize_sequence, args), **kwargs)
   1467     bound = new_sig.bind(ax, *args, **kwargs)
   1468     auto_label = (bound.arguments.get(label_namer)
   1469                   or bound.kwargs.get(label_namer))

TypeError: Axes.stem() got an unexpected keyword argument 'use_line_collection'

Desktop (please complete the following information):

  • OS: [MacOS
  • Python Version Python 3.11.5
  • Yellowbrick Version - not sure of the umber but I only just installed it and also ran a -u update, so believe it is the latest

Additional context
When I tried to find a solution online, the responses pointed to a change in Matplotlib form v3.8 onwards and I wondered if this si the issue (I assume Yellowbricks code would need altering to account for this update)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant