python-crfsuite icon indicating copy to clipboard operation
python-crfsuite copied to clipboard

TypeError: 'int' object is not iterable

Open JianfengQiao opened this issue 3 years ago • 1 comments

When run crf.fit(X_train, y_train) during the text classification task, pop up "TypeError: 'int' object is not iterable". X_train is the float array(Tfidf), y_train (series) is corresponding labels.

https://stackoverflow.com/questions/56285456/typeerror-numpy-int32-object-is-not-iterable-error-while-using-sklearn-crfs

JianfengQiao avatar Dec 09 '20 07:12 JianfengQiao

y_train should include label for each word and not only for each sentence, so it should be series of lists of labels. for example for the sentence "how are you", y_train should be a series that include one list [0,0,1] (random values, but the length should be 3, one label for each word)

yye1 avatar Nov 30 '21 00:11 yye1