skrub/string-encoder-hashing-vocabulary
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| skrub | error | none, edit by hand | All versions |
StringEncoder(vectorizer="hashing") uses scikit-learn's stateless HashingVectorizer, so passing a non-None vocabulary raises ValueError during fit.
enc = StringEncoder(vectorizer="hashing", vocabulary=["abc", "def"])enc = StringEncoder(vectorizer="tfidf", vocabulary=["abc", "def"])What the rule reports
Section titled “What the rule reports”Calls to StringEncoder that set vectorizer="hashing" together with a non-None vocabulary argument.
How to fix it
Section titled “How to fix it”Use vectorizer="tfidf" (the default) when supplying a fixed vocabulary, or omit vocabulary when using vectorizer="hashing".
Diagnostic message
Section titled “Diagnostic message”StringEncoder with vectorizer='hashing' does not support a custom vocabulary and raises ValueError at fit time. Use vectorizer='tfidf' or drop vocabulary=.See all rules in the skrub pack.