borfo
borfo

Reputation: 213

Is it possible to use countvectorizer with StandardScaler?

I am using countvectorizer to extract features, and I am wondering if I can scale the features. With the code below I am wondering if I can do some scaling using StandardScaler.

from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer()
x_training=vectorizer.fit_transform(df ['var'])

Upvotes: 0

Views: 1033

Answers (1)

Suraj Subbarao
Suraj Subbarao

Reputation: 89

as CountVectorizer creates a sparse matrix of features, the StandardScalar function from sklearn will throw an exception as it does'nt take sparse matrix.

Read the Docs.

Upvotes: 1

Related Questions