我尝试创建一个 SHAP 总结图,当它们提供如下时按特征值着色:
shap.summary_plot(shap_values, X_test_subset , feature_names=X_test_subset .columns, max_display=25)
但我得到了这个错误:
-------------------------------------------------- ------------------------- ValueError Traceback(最近一次调用最后一次)~/anaconda3/envs/naboo-env/lib/python3.6/site -packages/IPython/core/formatters.py in call (self, obj) 339 pass 340 else: --> 341 return printer(obj) 342 # 最后寻找特殊方法名 343 method = get_real_method(obj, self.print_method)
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/IPython/core/pylabtools.py in (fig) 242 243 if 'png' in formats: --> 244 png_formatter.for_type(图, lambda fig: print_figure(fig, 'png', **kwargs)) 245 if 'retina' in formats or 'png2x' in formats: 246 png_formatter.for_type(Figure, lambda fig:retina_figure(fig, **kwargs))
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/IPython/core/pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs) 126 127 bytes_io = BytesIO() --> 128 fig.canvas.print_figure(bytes_io, **kw) 129 数据 = bytes_io.getvalue() 130 如果 fmt == 'svg':
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/backend_bases.py in print_figure(自我,文件名,dpi,facecolor,edgecolor,方向,格式,**kwargs)2210
方向=方向, 2211 dryrun=True, -> 2212 **kwargs) 2213 渲染器 = self.figure._cachedRenderer 2214 bbox_inches = self.figure.get_tightbbox(renderer)~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs) 515 516 def print_png(self, filename_or_obj, *args, **kwargs): --> 517 FigureCanvasAgg.draw(self) 518 renderer = self.get_renderer() 519 original_dpi = renderer.dpi
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in draw(self) 435 # if toolbar: 436 # toolbar.set_cursor(cursors.WAIT) --> 437 self.figure.draw(self.renderer) 438 # 一个 GUI 类可能需要使用这个绘图来更新一个窗口,所以 439 # 不要忘记调用超类。
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 53 renderer.start_filter() 54 ---> 55 return draw(artist, renderer, *args, **kwargs) 56 finally: 57 如果 artist.get_agg_filter() 不是 None:
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/figure.py in draw(self, renderer) 1491 1492
mimage._draw_list_compositing_images(-> 1493 渲染器,self,artist,self.suppressComposite ) 1494 1495
渲染器.close_group('图')~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, Artists, suppress_composite) 139 if not_composite has_images: 140 for a in Artists: - -> 141 a.draw(renderer) 142 else: 143 # 将任何相邻的图像合成在一起
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 53 renderer.start_filter() 54 ---> 55 return draw(artist, renderer, *args, **kwargs) 56 finally: 57 如果 artist.get_agg_filter() 不是 None:
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/axes/_base.py in draw(self, renderer, inframe) 2633
renderer.stop_rasterizing() 2634 -> 2635 mimage._draw_list_compositing_images(渲染器,自我,艺术家)2636 2637 renderer.close_group('axes')~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, Artists, suppress_composite) 139 if not_composite has_images: 140 for a in Artists: - -> 141 a.draw(renderer) 142 else: 143 # 将任何相邻的图像合成在一起
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 53 renderer.start_filter() 54 ---> 55 return draw(artist, renderer, *args, **kwargs) 56 finally: 57 如果 artist.get_agg_filter() 不是 None:
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/collections.py in draw(self, renderer) 909 def draw(self, renderer): 910 self.set_sizes(self._sizes, self.figure.dpi) --> 911 Collection.draw(self, renderer) 912 913
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 53 renderer.start_filter() 54 ---> 55 return draw(artist, renderer, *args, **kwargs) 56 finally: 57 如果 artist.get_agg_filter() 不是 None:
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/collections.py in draw(self, renderer) 262 renderer.open_group( self.class.name , self.get_gid ()) 263 --> 264 self.update_scalarmappable() 265 266 变换,transOffset,偏移,路径 = self._prepare_points()
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/collections.py in update_scalarmappable(self) 806 return 807 if self._is_filled: --> 808 self._facecolors = self.to_rgba( self._A,self._alpha)809 elif self._is_stroked:810 self._edgecolors = self.to_rgba(self._A,self._alpha)
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/cm.py in to_rgba(self, x, alpha, bytes, norm) 272 x = ma.asarray(x) 273 if norm : --> 274 x = self.norm(x) 275 rgba = self.cmap(x, alpha=alpha, bytes=bytes) 276 return rgba
~/anaconda3/envs/naboo-env/lib/python3.6/site-packages/matplotlib/colors.py in call (self, value, clip) 945 result.fill(0) # 还是应该全部屏蔽?还是0.5?946 elif vmin > vmax: --> 947 raise ValueError("minvalue must be less than or equal to maxvalue") 948 else: 949 if clip:
ValueError:最小值必须小于或等于最大值