I’ve been trying to follow an NLP notebook, and they use:
from sklearn.feature_extraction import stop_words
However, this is throwing the following error:
ImportError: cannot import name 'stop_words' from 'sklearn.feature_extraction'
My guess is that stop_words is not (or maybe no longer) part of the ‘feature_extraction’ part of sklearn, but I might be wrong. I have seen some articles that used sklearn.feature_extraction.stop_words, but at the same time I see places which have used ‘text’ in place of ‘feature_extraction’.
Am I misunderstanding something? sklearn is definitely up to date (version 0.24) and I import something from sklearn.manifold earlier in the notebook.
Thanks for your help!
Advertisement
Answer
I have sklearn
version 0.24.1, and I found that the module is now private – it’s called _stop_words
. So:
from sklearn.feature_extraction import _stop_words
After a little digging, I found that this change was made in version 0.22, in response to this issue. It looks like they want people to use the “canonical” import for the task at hand, as described in the API docs.