scrapinghub / python-crfsuite

A python binding for crfsuite
MIT License
769 stars 223 forks source link

TypeError: 'int' object is not iterable #125

Open JianfengQiao opened 3 years ago

JianfengQiao commented 3 years ago

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

yye1 commented 2 years ago

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)