How to set custom stop words for sklearn CountVectorizer?
<p>I'm trying to run LDA (Latent Dirichlet Allocation) on a non-English text dataset.</p>

<p>From sklearn's tutorial, there's this part where you count term frequency of the words to feed into the LDA:</p>

<pre><code>tf_vectorizer = CountVectorizer(max_df=0.95, min_df=2,
                            max_features=n_features,
                            stop_words='english')
</code></pre>

<p>Which has built-in stop words feature which is only available for English I think. How could I use my own stop words list for this?</p>

<p>You may just assign a <code>frozenset</code> of your own words to the <a href="https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/feature_extraction/stop_words.py" rel="nofollow"><code>stop_words</code> argument</a>, e.g.:</p>

<pre><code>stop_words = frozenset(["word1", "word2","word3"])
</code></pre>

python machine-learning scikit-learn nlp