Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Small bug in BM25Transformer #3

Open
conan1024hao opened this issue Nov 2, 2022 · 0 comments
Open

Small bug in BM25Transformer #3

conan1024hao opened this issue Nov 2, 2022 · 0 comments

Comments

@conan1024hao
Copy link

check_is_fitted in BM25Transformer does not work well with scikit-learn 1.0.1.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_1719/4208231121.py in <module>
----> 1 X_test = bm25.fit_transform(test_corpus)

/usr/local/lib64/python3.7/site-packages/sklearn/pipeline.py in fit_transform(self, X, y, **fit_params)
    432             fit_params_last_step = fit_params_steps[self.steps[-1][0]]
    433             if hasattr(last_step, "fit_transform"):
--> 434                 return last_step.fit_transform(Xt, y, **fit_params_last_step)
    435             else:
    436                 return last_step.fit(Xt, y, **fit_params_last_step).transform(Xt)

/usr/local/lib64/python3.7/site-packages/sklearn/base.py in fit_transform(self, X, y, **fit_params)
    845         if y is None:
    846             # fit method of arity 1 (unsupervised transformation)
--> 847             return self.fit(X, **fit_params).transform(X)
    848         else:
    849             # fit method of arity 2 (supervised transformation)

/tmp/ipykernel_1719/3233856808.py in transform(self, X, copy)
     80 
     81         if self.use_idf:
---> 82             check_is_fitted(self, '_idf_diag', 'idf vector is not fitted')
     83 
     84             expected_n_features = self._idf_diag.shape[0]

TypeError: check_is_fitted() takes from 1 to 2 positional arguments but 3 were given

After changing the code to the below one, the error was resolved.

check_is_fitted(self, attributes='_idf_diag', msg='idf vector is not fitted')
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant