ValueError Traceback (most recent call last)
Cell In[129], line 7
3 coefficients = [-2.713712e-02,1.917585e-02,-1.619617e-02,-1.245247e-02,-1.196426e-02,-7.996985e-03,-7.859375e-03,6.864546e-03,6.558818e-03,-4.640525e-03,
4 -2.989272e-03,-2.384312e-03,-1.860149e-03,1.551288e-03,5.374756e-18]
6 fig, ax = plt.subplots(figsize=(10, 6))
----> 7 ax.barh(features, coefficients, color='skyblue')
8 ax.set_xlabel('Coefficient Value')
9 ax.set_ylabel('Features')
File D:\anaconda3\Lib\site-packages\matplotlib\axes\_axes.py:2812, in Axes.barh(self, y, width, height, left, align, data, **kwargs)
2693 r"""
2694 Make a horizontal bar plot.
2695
(...)
2809 :doc:`/gallery/lines_bars_and_markers/horizontal_barchart_distribution`.
2810 """
2811 kwargs.setdefault('orientation', 'horizontal')
-> 2812 patches = self.bar(x=left, height=height, width=width, bottom=y,
2813 align=align, data=data, **kwargs)
2814 return patches
File D:\anaconda3\Lib\site-packages\matplotlib\__init__.py:1521, in _preprocess_data.<locals>.inner(ax, data, *args, **kwargs)
1518 @functools.wraps(func)
1519 def inner(ax, *args, data=None, **kwargs):
1520 if data is None:
-> 1521 return func(
1522 ax,
1523 *map(cbook.sanitize_sequence, args),
1524 **{k: cbook.sanitize_sequence(v) for k, v in kwargs.items()})
1526 bound = new_sig.bind(ax, *args, **kwargs)
1527 auto_label = (bound.arguments.get(label_namer)
1528 or bound.kwargs.get(label_namer))
File D:\anaconda3\Lib\site-packages\matplotlib\axes\_axes.py:2572, in Axes.bar(self, x, height, width, bottom, align, **kwargs)
2569 if yerr is not None:
2570 yerr = self._convert_dx(yerr, y0, y, self.convert_yunits)
-> 2572 x, height, width, y, linewidth, hatch = np.broadcast_arrays(
2573 # Make args iterable too.
2574 np.atleast_1d(x), height, width, y, linewidth, hatch)
2576 # Now that units have been converted, set the tick locations.
2577 if orientation == 'vertical':
File D:\anaconda3\Lib\site-packages\numpy\lib\_stride_tricks_impl.py:558, in broadcast_arrays(subok, *args)
551 # nditer is not used here to avoid the limit of 32 arrays.
552 # Otherwise, something like the following one-liner would suffice:
553 # return np.nditer(args, flags=['multi_index', 'zerosize_ok'],
554 # order='C').itviews
556 args = [np.array(_m, copy=None, subok=subok) for _m in args]
--> 558 shape = _broadcast_shape(*args)
560 result = [array if array.shape == shape
561 else _broadcast_to(array, shape, subok=subok, readonly=False)
562 for array in args]
563 return tuple(result)
File D:\anaconda3\Lib\site-packages\numpy\lib\_stride_tricks_impl.py:433, in _broadcast_shape(*args)
428 """Returns the shape of the arrays that would result from broadcasting the
429 supplied arrays against each other.
430 """
431 # use the old-iterator because np.nditer does not handle size 0 arrays
432 # consistently
--> 433 b = np.broadcast(*args[:32])
434 # unfortunately, it cannot handle 32 or more arguments directly
435 for pos in range(32, len(args), 31):
436 # ironically, np.broadcast does not properly handle np.broadcast
437 # objects (it treats them as scalars)
438 # use broadcasting to avoid allocating the full array
ValueError: shape mismatch: objects cannot be broadcast to a single shape. Mismatch is between arg 2 with shape (15,) and arg 3 with shape (14,).
D:\anaconda3\Lib\site-packages\IPython\core\events.py:82: UserWarning: Glyph 31070 (\N{CJK UNIFIED IDEOGRAPH-795E}) missing from font(s) DejaVu Sans.
func(*args, **kwargs)
D:\anaconda3\Lib\site-packages\IPython\core\events.py:82: UserWarning: Glyph 32463 (\N{CJK UNIFIED IDEOGRAPH-7ECF}) missing from font(s) DejaVu Sans.
func(*args, **kwargs)
D:\anaconda3\Lib\site-packages\IPython\core\events.py:82: UserWarning: Glyph 20256 (\N{CJK UNIFIED IDEOGRAPH-4F20}) missing from font(s) DejaVu Sans.
func(*args, **kwargs)
D:\anaconda3\Lib\site-packages\IPython\core\events.py:82: UserWarning: Glyph 23548 (\N{CJK UNIFIED IDEOGRAPH-5BFC}) missing from font(s) DejaVu Sans.
func(*args, **kwargs)
D:\anaconda3\Lib\site-packages\IPython\core\events.py:82: UserWarning: Glyph 24773 (\N{CJK UNIFIED IDEOGRAPH-60C5}) missing from font(s) DejaVu Sans.
func(*args, **kwargs)
D:\anaconda3\Lib\site-packages\IPython\core\events.py:82: UserWarning: Glyph 20917 (\N{CJK UNIFIED IDEOGRAPH-51B5}) missing from font(s) DejaVu Sans.
func(*args, **kwargs)
D:\anaconda3\Lib\site-packages\IPython\core\pylabtools.py:170: UserWarning: Glyph 31070 (\N{CJK UNIFIED IDEOGRAPH-795E}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
D:\anaconda3\Lib\site-packages\IPython\core\pylabtools.py:170: UserWarning: Glyph 32463 (\N{CJK UNIFIED IDEOGRAPH-7ECF}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
D:\anaconda3\Lib\site-packages\IPython\core\pylabtools.py:170: UserWarning: Glyph 20256 (\N{CJK UNIFIED IDEOGRAPH-4F20}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
D:\anaconda3\Lib\site-packages\IPython\core\pylabtools.py:170: UserWarning: Glyph 23548 (\N{CJK UNIFIED IDEOGRAPH-5BFC}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
D:\anaconda3\Lib\site-packages\IPython\core\pylabtools.py:170: UserWarning: Glyph 24773 (\N{CJK UNIFIED IDEOGRAPH-60C5}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
D:\anaconda3\Lib\site-packages\IPython\core\pylabtools.py:170: UserWarning: Glyph 20917 (\N{CJK UNIFIED IDEOGRAPH-51B5}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
最新发布