undertheseanlp / underthesea

Underthesea - Vietnamese NLP Toolkit
http://undertheseanlp.com
GNU General Public License v3.0
1.35k stars 270 forks source link

Incompatibility with sklearn >= 1.5 #731

Open BLKSerene opened 1 month ago

BLKSerene commented 1 month ago

Hi, underthesea 6.8.0 is incompatible with the latest scikit-learn 1.5.0:

import underthesea
underthesea.sentiment('test')
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    underthesea.sentiment('test')
  File "D:\Python\lib\site-packages\underthesea\pipeline\sentiment\__init__.py", line 33, in sentiment
    return sentiment(X)
  File "D:\Python\lib\site-packages\underthesea\pipeline\sentiment\general\__init__.py", line 23, in sentiment
    classifier.predict(sentence)
  File "D:\Python\lib\site-packages\underthesea\models\text_classifier.py", line 97, in predict
    y = self.pipeline.predict([text])
  File "D:\Python\lib\site-packages\sklearn\pipeline.py", line 603, in predict
    Xt = transform.transform(Xt)
  File "D:\Python\lib\site-packages\sklearn\feature_extraction\text.py", line 2118, in transform
    return self._tfidf.transform(X, copy=False)
  File "D:\Python\lib\site-packages\sklearn\feature_extraction\text.py", line 1689, in transform
    check_is_fitted(self)
  File "D:\Python\lib\site-packages\sklearn\utils\validation.py", line 1632, in check_is_fitted
    raise NotFittedError(msg % {"name": type(estimator).__name__})
sklearn.exceptions.NotFittedError: This TfidfTransformer instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.

Downgrading to scikit-learn 1.4.2 works.

OS: Windows 11 x64 Python: 3.10.13 x64 Underthesea: 6.8.0