#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
Комментарии:
1. Когда вопрос связан с библиотекой, такой как, например, tensorflow, добавьте соответствующие теги.