Skip to content

chapter05: invalid parameter, in TfidfVectorizer #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bmerkle opened this issue Jan 4, 2025 · 0 comments · May be fixed by #35
Open

chapter05: invalid parameter, in TfidfVectorizer #34

bmerkle opened this issue Jan 4, 2025 · 0 comments · May be fixed by #35

Comments

@bmerkle
Copy link

bmerkle commented Jan 4, 2025

from spacy.lang.en.stop_words import STOP_WORDS as stopwords
print(len(stopwords))
tfidf = TfidfVectorizer(stop_words=list(stopwords))
dt = tfidf.fit_transform(headlines["headline_text"])
dt

error message:

---------------------------------------------------------------------------
InvalidParameterError                     Traceback (most recent call last)
Cell In[33], [line 4](vscode-notebook-cell:?execution_count=33&line=4)
      [2](vscode-notebook-cell:?execution_count=33&line=2) print(len(stopwords))
      [3](vscode-notebook-cell:?execution_count=33&line=3) tfidf = TfidfVectorizer(stop_words=stopwords)
----> [4](vscode-notebook-cell:?execution_count=33&line=4) dt = tfidf.fit_transform(headlines["headline_text"])
      [5](vscode-notebook-cell:?execution_count=33&line=5) dt

fix:
tfidf = TfidfVectorizer(stop_words=list(stopwords))
or we could use
tfidf = TfidfVectorizer(stop_words='english')

there are several places where this has to be fixed in the chapter05 notebook

@christianw @datanizing

@bmerkle bmerkle linked a pull request Jan 4, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant