【问题标题】:Is it possible to use countvectorizer with StandardScaler?是否可以将 countvectorizer 与 StandardScaler 一起使用?
【发布时间】:2018-11-08 00:04:01
【问题描述】:

我正在使用 countvectorizer 来提取特征,我想知道是否可以缩放特征。通过下面的代码,我想知道是否可以使用 StandardScaler 进行一些缩放。

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

【问题讨论】:

    标签: python scikit-learn nlp


    【解决方案1】:

    由于 CountVectorizer 创建特征的稀疏矩阵,来自 sklearn 的 StandardScalar 函数将抛出异常,因为它不采用稀疏矩阵。

    阅读Docs

    【讨论】:

      猜你喜欢
      • 2021-11-12
      • 2016-04-01
      • 2011-01-20
      • 2018-08-11
      • 2021-08-05
      • 2019-03-18
      • 2014-03-15
      • 2021-03-31
      • 2020-12-22
      相关资源
      最近更新 更多