0

I am solving a numeric Multi label classification problem while fitting the model.

I had checked my columns if there is any problem i did not found any problem with features or class labels

enter code here

X_train, X_test, y_train, y_test = train_test_split(data, train_label, test_size=0.33, random_state=42)    classifier = MLkNN(k=10)    x_train = lil_matrix(X_train).toarray()    y_train = lil_matrix(y_train).toarray()    x_test = lil_matrix(X_test).toarray() 
    classifier.fit(x_train, y_train)    IndexError: column index (383) out of bounds

I want to know,

what is this error means? How to handle this error?.

Ryan Wilson
  • 10,223
  • 2
  • 21
  • 40

1 Answers1

0

The error simply states that you are trying to access an index that does not exist. In your case, you are trying to access item in index 383, but index 383 does not exist. Example: myList = ['a','b']. If you want myList[2], you will get the IndexError.

My suspicion is that since you are using lil_matrix() on both X_train and y_train, they are not incrementing in the same pace and therefore is out of sync in terms of indexes.

I don't have the full context of your code, so I can't say for sure. Have you tried not using lil_matrix? Check the lengths of X_train and y_train after applying lil_matrix

Azmain Amin
  • 23
  • 1
  • 3