---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[14], line 5
2 X_set, y_set = X_test, y_test
3 X1, X2 = np.meshgrid(np.arange(start = X_set[:, 0].min() - 1, stop = X_set[:, 0].max() + 1, step = 0.01),
4 np.arange(start = X_set[:, 1].min() - 1, stop = X_set[:, 1].max() + 1, step = 0.01))
----> 5 plt.contourf(X1, X2, classifier.predict(np.array([X1.ravel(), X2.ravel()]).T).reshape(X1.shape),
6 alpha = 0.75, cmap = ListedColormap(('red', 'green')))
7 plt.xlim(X1.min(), X1.max())
8 plt.ylim(X2.min(), X2.max())
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/pyplot.py:2938, in contourf(data, *args, **kwargs)
2936 @_copy_docstring_and_deprecators(Axes.contourf)
2937 def contourf(*args, data=None, **kwargs) -> QuadContourSet:
-> 2938 __ret = gca().contourf(
2939 *args, **({"data": data} if data is not None else {}), **kwargs
2940 )
2941 if __ret._A is not None: # type: ignore[attr-defined]
2942 sci(__ret)
File ~/miniconda3/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))
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/axes/_axes.py:6528, in Axes.contourf(self, *args, **kwargs)
6519 """
6520 Plot filled contours.
6521
(...)
6525 %(contour_doc)s
6526 """
6527 kwargs['filled'] = True
-> 6528 contours = mcontour.QuadContourSet(self, *args, **kwargs)
6529 self._request_autoscale_view()
6530 return contours
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/contour.py:887, in ContourSet.__init__(self, ax, levels, filled, linewidths, linestyles, hatches, alpha, origin, extent, cmap, colors, norm, vmin, vmax, extend, antialiased, nchunk, locator, transform, negative_linestyles, clip_path, *args, **kwargs)
884 self.labelTexts = []
885 self.labelCValues = []
--> 887 self.set_cmap(cmap)
888 if norm is not None:
889 self.set_norm(norm)
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/cm.py:602, in ScalarMappable.set_cmap(self, cmap)
600 self.cmap = _ensure_cmap(cmap)
601 if not in_init:
--> 602 self.changed()
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/contour.py:1145, in ContourSet.changed(self)
1143 def changed(self):
1144 if not hasattr(self, "cvalues"):
-> 1145 self._process_colors() # Sets cvalues.
1146 # Force an autoscale immediately because self.to_rgba() calls
1147 # autoscale_None() internally with the data passed to it,
1148 # so if vmin/vmax are not set yet, this would override them with
1149 # content from *cvalues* rather than levels like we want
1150 self.norm.autoscale_None(self.levels)
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/contour.py:1302, in ContourSet._process_colors(self)
1300 else:
1301 self.cvalues = self.layers
-> 1302 self.norm.autoscale_None(self.levels)
1303 self.set_array(self.cvalues)
1304 self.update_scalarmappable()
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/colors.py:1408, in Normalize.autoscale_None(self, A)
1405 A = A.data
1407 if self.vmin is None and A.size:
-> 1408 self.vmin = A.min()
1409 if self.vmax is None and A.size:
1410 self.vmax = A.max()
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/colors.py:1264, in Normalize.vmin(self, value)
1262 if value != self._vmin:
1263 self._vmin = value
-> 1264 self._changed()
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/colors.py:1292, in Normalize._changed(self)
1287 def _changed(self):
1288 """
1289 Call this whenever the norm is changed to notify all the
1290 callback listeners to the 'changed' signal.
1291 """
-> 1292 self.callbacks.process('changed')
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/cbook.py:303, in CallbackRegistry.process(self, s, *args, **kwargs)
301 except Exception as exc:
302 if self.exception_handler is not None:
--> 303 self.exception_handler(exc)
304 else:
305 raise
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/cbook.py:87, in _exception_printer(exc)
85 def _exception_printer(exc):
86 if _get_running_interactive_framework() in ["headless", None]:
---> 87 raise exc
88 else:
89 traceback.print_exc()
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/cbook.py:298, in CallbackRegistry.process(self, s, *args, **kwargs)
296 if func is not None:
297 try:
--> 298 func(*args, **kwargs)
299 # this does not capture KeyboardInterrupt, SystemExit,
300 # and GeneratorExit
301 except Exception as exc:
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/contour.py:1150, in ContourSet.changed(self)
1145 self._process_colors() # Sets cvalues.
1146 # Force an autoscale immediately because self.to_rgba() calls
1147 # autoscale_None() internally with the data passed to it,
1148 # so if vmin/vmax are not set yet, this would override them with
1149 # content from *cvalues* rather than levels like we want
-> 1150 self.norm.autoscale_None(self.levels)
1151 self.set_array(self.cvalues)
1152 self.update_scalarmappable()
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/colors.py:1410, in Normalize.autoscale_None(self, A)
1408 self.vmin = A.min()
1409 if self.vmax is None and A.size:
-> 1410 self.vmax = A.max()
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/colors.py:1275, in Normalize.vmax(self, value)
1273 if value != self._vmax:
1274 self._vmax = value
-> 1275 self._changed()
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/colors.py:1292, in Normalize._changed(self)
1287 def _changed(self):
1288 """
1289 Call this whenever the norm is changed to notify all the
1290 callback listeners to the 'changed' signal.
1291 """
-> 1292 self.callbacks.process('changed')
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/cbook.py:303, in CallbackRegistry.process(self, s, *args, **kwargs)
301 except Exception as exc:
302 if self.exception_handler is not None:
--> 303 self.exception_handler(exc)
304 else:
305 raise
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/cbook.py:87, in _exception_printer(exc)
85 def _exception_printer(exc):
86 if _get_running_interactive_framework() in ["headless", None]:
---> 87 raise exc
88 else:
89 traceback.print_exc()
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/cbook.py:298, in CallbackRegistry.process(self, s, *args, **kwargs)
296 if func is not None:
297 try:
--> 298 func(*args, **kwargs)
299 # this does not capture KeyboardInterrupt, SystemExit,
300 # and GeneratorExit
301 except Exception as exc:
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/contour.py:1152, in ContourSet.changed(self)
1150 self.norm.autoscale_None(self.levels)
1151 self.set_array(self.cvalues)
-> 1152 self.update_scalarmappable()
1153 alphas = np.broadcast_to(self.get_alpha(), len(self.cvalues))
1154 for label, cv, alpha in zip(self.labelTexts, self.labelCValues, alphas):
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/collections.py:920, in Collection.update_scalarmappable(self)
918 # pcolormesh, scatter, maybe others flatten their _A
919 self._alpha = self._alpha.reshape(self._A.shape)
--> 920 self._mapped_colors = self.to_rgba(self._A, self._alpha)
922 if self._face_is_mapped:
923 self._facecolors = self._mapped_colors
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/cm.py:509, in ScalarMappable.to_rgba(self, x, alpha, bytes, norm)
507 if norm:
508 x = self.norm(x)
--> 509 rgba = self.cmap(x, alpha=alpha, bytes=bytes)
510 return rgba
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/colors.py:725, in Colormap.__call__(self, X, alpha, bytes)
702 r"""
703 Parameters
704 ----------
(...)
722 RGBA values with a shape of ``X.shape + (4, )``.
723 """
724 if not self._isinit:
--> 725 self._init()
727 xa = np.array(X, copy=True)
728 if not xa.dtype.isnative:
729 # Native byteorder is faster.
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/colors.py:1175, in ListedColormap._init(self)
1173 def _init(self):
1174 self._lut = np.zeros((self.N + 3, 4), float)
-> 1175 self._lut[:-3] = to_rgba_array(self.colors)
1176 self._isinit = True
1177 self._set_extremes()
File ~/miniconda3/lib/python3.11/site-packages/matplotlib/colors.py:489, in to_rgba_array(c, alpha)
487 raise e
488 if isinstance(c, str):
--> 489 raise ValueError(f"{c!r} is not a valid color value.")
491 if len(c) == 0:
492 return np.zeros((0, 4), float)
ValueError: 'red' is not a valid color value.