AxisError: axis 1 is out of bounds for array of dimension 1 I've used svm classifier. Now I need to construct the confusion matrix. Here is the code that I have used.

from sklearn.svm import SVC

svm = SVC(kernel='rbf')

svm.fit(feat_train,np.argmax(Y_train,axis=1))
svm.score(feat_train,np.argmax(Y_train,axis=1))
svm.score(feat_val,np.argmax(Y_val,axis=1))
y_pred = svm.predict(feat_val)
y_pred.shape
(950,)
y_class = np.argmax(y_pred, axis = 1) 
y_check = np.argmax(Y_val, axis = 1) 

cmatrix = confusion_matrix(y_check, y_class)
print(cmatrix)
print('accuracy Score :'),accuracy_score(y_check, y_class) 

print('Report : ')
print(classification_report(y_check, y_class))


I'm getting the following error

---------------------------------------------------------------------------
AxisError                                 Traceback (most recent call last)
&lt;ipython-input-102-67006c959068&gt; in &lt;module&gt;
----&gt; 1 y_class = np.argmax(y_pred, axis = 1)
      2 y_check = np.argmax(Y_val, axis = 1)
      3 
      4 cmatrix = confusion_matrix(y_check, y_class)
      5 print(cmatrix)

~\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py in argmax(a, axis, out)
   1101 
   1102     """
-&gt; 1103     return _wrapfunc(a, 'argmax', axis=axis, out=out)
   1104 
   1105 

~\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
     54 def _wrapfunc(obj, method, *args, **kwds):
     55     try:
---&gt; 56         return getattr(obj, method)(*args, **kwds)
     57 
     58     # An AttributeError occurs if the object does not have

AxisError: axis 1 is out of bounds for array of dimension 1


I think the problem is with y_pred as the dimension is given as (950,). Please help me solve this
y_class = np.argmax(y_pred, axis = 1)

here axis=1 represents check max value index column wise
you are facing the error because you are passing vector (size,)
y_class = np.argmax(y_pred, axis = 0)

use above code to remove the error