简体   繁体   English

分类器:轴 1 超出维度 1 数组的范围

[英]classifier : axis 1 is out of bounds for array of dimension 1

I'm using ScikitlearnRandomForestClassifier as below.我正在使用 ScikitlearnRandomForestClassifier 如下。

from art.estimators.classification.scikitlearn import ScikitlearnRandomForestClassifier as SRFC
from sklearn.ensemble import RandomForestClassifier as RFC

model_rand_forest = SRFC(RFC(n_estimators=500,
                             max_depth=45,
                             criterion='entropy',
                             random_state=32))
model_rand_forest = model_rand_forest.fit(x_train, y_train)

I ran into the following error.我遇到了以下错误。 If needed, y_train is a series of the size (70540,) and x_train is of the size (70540, 128) .如果需要, y_train是一系列大小(70540,)x_train是大小(70540, 128)

error:
 File "<ipython-input-18-c410427d7973>", line 1, in <module>
    model_rand_forest = model_rand_forest.fit(x_train , y_train)

  File "E:\Anaconda3\lib\site-packages\art\estimators\classification\classifier.py", line 71, in replacement_function
    return fdict[func_name](self, *args, **kwargs)

  File "E:\Anaconda3\lib\site-packages\art\estimators\classification\scikitlearn.py", line 138, in fit
    y_preprocessed = np.argmax(y_preprocessed, axis=1)

  File "<__array_function__ internals>", line 6, in argmax

  File "E:\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 1186, in argmax
    return _wrapfunc(a, 'argmax', axis=axis, out=out)

  File "E:\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 61, in _wrapfunc
    return bound(*args, **kwds)

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

you will have to provide the labels y one-hot encoded with shape (nb_samples, nb_classes) to the ART estimators for scikit-learn models.您必须向 scikit-learn 模型的 ART 估计器提供使用形状 (nb_samples, nb_classes) 编码的标签 y。 you can use this link to put your labels in one-hot format.您可以使用此链接将您的标签置于 one-hot 格式中。 https://machinelearningmastery.com/how-to-one-hot-encode-sequence-data-in-python/ https://machinelearningmastery.com/how-to-one-hot-encode-sequence-data-in-python/

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

相关问题 AxisError:轴 1 超出维度 1 数组的范围 - AxisError: axis 1 is out of bounds for array of dimension 1 遇到 AxisError:轴 1 超出维度 0 数组的范围 - Encountering AxisError: axis 1 is out of bounds for array of dimension 0 numpy.AxisError:轴 1 超出维度 1 数组的范围 - numpy 数组 - numpy.AxisError: axis 1 is out of bounds for array of dimension 1 - numpy array np.linalg.norm AxisError:轴 1 超出维度 1 数组的范围 - np.linalg.norm AxisError: axis 1 is out of bounds for array of dimension 1 AxisError:计算类的准确性时,轴 1 超出维度 1 数组的范围 - AxisError: axis 1 is out of bounds for array of dimension 1 when calculating accuracy of classes 我无法解决“轴-1超出维度0数组的范围”的问题 - I can't solve issue “axis -1 is out of bounds for array of dimension 0” Numpy 连接给出错误:轴 1 超出维度 1 数组的范围 - Numpy concatenate giving error: axis 1 is out of bounds for array of dimension 1 如何解决 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 轴超出范围 - axis out of bounds with array
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM