简体   繁体   English

AxisError:计算类的准确性时,轴 1 超出维度 1 数组的范围

[英]AxisError: axis 1 is out of bounds for array of dimension 1 when calculating accuracy of classes

I try to predict 10 classes using this code我尝试使用此代码预测 10 个类

#Predicting the Test set rules
y_pred = model.predict(traindata)
y_pred = np.argmax(y_pred, axis=1) 
y_true = np.argmax(testdata, axis=1) 

target_names = ["akLembut","akMundur","akTajam","caMenaik", "caMenurun", "coretanTengah", "garisAtas", "garisBawah", "garisBawahBanyak", "ttdCangkang"]
print("\n"+ classification_report(y_true, y_pred, target_names=target_names))

But then I got an error message like this但后来我收到这样的错误消息

AxisError                                 Traceback (most recent call last)
<ipython-input-13-a2b02b251547> in <module>()
      2 y_pred = model.predict(traindata)
      3 y_pred = np.argmax(y_pred, axis=1)
----> 4 y_true = np.argmax(testdata, axis=1)
      5 
      6 target_names = ["akLembut","akMundur","akTajam","caMenaik", "caMenurun", "coretanTengah", "garisAtas", "garisBawah", "garisBawahBanyak", "ttdCangkang"]

<__array_function__ internals> in argmax(*args, **kwargs)

2 frames
/usr/local/lib/python3.6/dist-packages/numpy/core/fromnumeric.py in _wrapit(obj, method, *args, **kwds)
     45     except AttributeError:
     46         wrap = None
---> 47     result = getattr(asarray(obj), method)(*args, **kwds)
     48     if wrap:
     49         if not isinstance(result, mu.ndarray):

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

I already train the data and I need to know each accuracy.我已经训练了数据,我需要知道每一个准确度。

My guess is that your test_data array is only one-dimensional, so change to y_true = np.argmax(testdata, axis=0) .我的猜测是您的test_data数组只是一维的,因此更改为y_true = np.argmax(testdata, axis=0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AxisError:计算 roc_auc_score 时,轴 1 超出维度 1 数组的范围 - AxisError: axis 1 is out of bounds for array of dimension 1 when calculating roc_auc_score 遇到 AxisError:轴 1 超出维度 0 数组的范围 - Encountering AxisError: axis 1 is out of bounds for array of dimension 0 AxisError:轴 1 超出维度 1 数组的范围 - AxisError: axis 1 is out of bounds for array of dimension 1 numpy.AxisError:轴 1 超出维度 1 数组的范围 - numpy 数组 - numpy.AxisError: axis 1 is out of bounds for array of dimension 1 - numpy array 如何解决 AxisError:轴 1 超出维度 0 数组的范围 - How to solve AxisError: axis 1 is out of bounds for array of dimension 0 numpy.AxisError:来源:轴 2 超出了维度 2 数组的范围 - numpy.AxisError: source: axis 2 is out of bounds for array of dimension 2 np.linalg.norm AxisError:轴 1 超出维度 1 数组的范围 - np.linalg.norm AxisError: axis 1 is out of bounds for array of dimension 1 2D 数组的 median_absolute_deviation 抛出 AxisError: axis 1 is out of bounds for array of dimension 1 - median_absolute_deviation of 2D array throws AxisError: axis 1 is out of bounds for array of dimension 1 分类器:轴 1 超出维度 1 数组的范围 - classifier : axis 1 is out of bounds for array of dimension 1 我无法解决“轴-1超出维度0数组的范围”的问题 - I can't solve issue “axis -1 is out of bounds for array of dimension 0”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM