質問
学習中の書籍のコードを写していたら本来出ないはずのエラーがでてしまいました。エラー文の意味もよく分からず困っています。何が原因なのでしょうか?変数XXもYYも.shapeは(50.50)の二次元配列です。
発生している問題・エラーメッセージ
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Input In [160], in <cell line: 2>() 1 ZZ = YY ** 2 ----> 2 dec = linear_svm_3d.decision_function(np.c_[XX.ravel(), YY.ravel, ZZ.ravel()]) 3 plt.contourf(XX,YY, dec.reshape(XX.shape), levels=[dec.min(),0,dec.max()],cmap=mglearn.cm2,alpha=0.5) 4 mglearn.discrete_scatter(X[:,0],X[:,1],y) File ~\anaconda3\lib\site-packages\numpy\lib\index_tricks.py:413, in AxisConcatenator.__getitem__(self, key) 410 for k in scalars: 411 objs[k] = objs[k].astype(final_dtype) --> 413 res = self.concatenate(tuple(objs), axis=axis) 415 if matrix: 416 oldndim = res.ndim File <__array_function__ internals>:5, in concatenate(*args, **kwargs) ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 2500 and the array at index 1 has size 1
該当のソースコード
Python
1ZZ = YY ** 2 2dec = linear_svm_3d.decision_function(np.c_[XX.ravel(), YY.ravel, ZZ.ravel()]) 3plt.contourf(XX,YY, dec.reshape(XX.shape), levels=[dec.min(),0,dec.max()],cmap=mglearn.cm2,alpha=0.5) 4mglearn.discrete_scatter(X[:,0],X[:,1],y)
YY.ravel
↓ 修正
YY.ravel()
【追記】
can110さんの回答と被った
失礼しました
回答1件
あなたの回答
tips
プレビュー