索引错误:索引 73922 超出轴 0 的范围,大小为 73920

时间:2021-07-11 09:01:01

标签: python index-error ensemble-learning fuzzy

我尝试构建FRNN的模型:

for i, owa_weights, k in [(1, strict(), 1), (2, additive(), 20)]:
  # Create an instance of the FRNN classifier, construct the model, and query on the test set.
  clf = FRNN(nn_search=nn_search, upper_weights=owa_weights, lower_weights=owa_weights, lower_k=k, upper_k=k)
  cl = clf.construct(X_train, y)
  scores = model(X_test)

但我收到一个错误:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-81-4d508eeca158> in <module>()
      7   # Create an instance of the FRNN classifier, construct the model, and query on the test set.
      8   clf = FRNN(nn_search=nn_search, upper_weights=owa_weights, lower_weights=owa_weights, lower_k=k, upper_k=k)
----> 9   cl = clf.construct(X_train, y)
     10   scores = model(X_test)

2 frames
/content/frlearn/neighbours/classifiers.py in <listcomp>(.0)
     24     def construct(self, X, y) -> Model:
     25         model: FuzzyRoughEnsemble.Model = super().construct(X, y)
---> 26         Cs = [X[np.where(y == c)] for c in model.classes]
     27         model.upper_approximations = self.upper_approximator and [self.upper_approximator.construct(C) for C in Cs]
     28         co_Cs = [X[np.where(y != c)] for c in model.classes]

IndexError: index 73922 is out of bounds for axis 0 with size 73920

X_train 的形状是 (73920,300) 然后我试着像这样运行:

cl = clf.construct(X_train[-2:73920], y)

但我收到一个错误:

IndexError: index 49 is out of bounds for axis 0 with size 2

以下是错误信息的详细信息: error messages

0 个答案:

没有答案