【问题标题】:How to feature-select scikit transformers within FeatureUnion如何在 FeatureUnion 中对 scikit 转换器进行特征选择
【发布时间】:2021-12-09 12:31:44
【问题描述】:

我有一个机器学习分类任务,它从各种固定长度向量表示的串联中进行训练。如何在 scikit-learn 中执行自动特征选择或网格搜索或任何其他已建立的技术来为我的数据找到最佳的转换器组合?

以这个文本分类流程为例:

model = Pipeline([
   ('vectorizer', FeatureUnion(transformer_list=[
      ('word-freq', TfidfVectorizer()),        # vocab-size dimensional
      ('doc2vec', MyDoc2VecVectorizer()),      # 32 dimensional (custom transformer)
      ('doc-length', MyDocLengthVectorizer()), # 1 dimensional (custom transformer)
      ('sentiment', MySentimentVectorizer()),  # 3 dimensional (custom transformer)
      ...                                      # possibly many other transformers
   ])),
   ('classifier', SVC())
])

我怀疑这可能属于scikit slep002 请求的dynamic-pipeline 功能。如果可以,中途怎么处理?

【问题讨论】:

    标签: machine-learning scikit-learn feature-selection grid-search


    【解决方案1】:

    虽然不太能够“选择最好的(全部或全部)转换器特性子集”,但我们可以使用 scikit 的 feature selectiondimensionality reduction 模块来“选择/简化跨所有转换器的最佳特征子集”作为分类前的额外步骤:

    model = Pipeline([
       ('vectorizer', FeatureUnion(transformer_list=[...])),
       ('feature_selector', GenericUnivariateSelect(
          mode='percentile',
          param=0.20,          # hyper-tunable parameter
       )),
       ('classifier', SVC())
    ])
    

    在特征发现上下文中(即:找到最佳表达信号),这种技术比挑选变压器更强大。然而,在架构发现环境中(即:找到最佳管道布局和转换器的使用),这个问题似乎仍然悬而未决..

    【讨论】:

      猜你喜欢
      • 2021-03-26
      • 2014-11-05
      • 2020-01-29
      • 2019-10-22
      • 2016-08-30
      • 2018-05-13
      • 2018-02-24
      • 2021-02-11
      相关资源
      最近更新 更多