【问题标题】:Setting n_features_to_select RFE as percentage in pipeline在管道中将 n_features_to_select RFE 设置为百分比
【发布时间】:2017-07-19 12:34:17
【问题描述】:

我有这样的管道:

lin_reg_pipeline = Pipeline([
    ('polynomial_features', PolynomialFeatures()),
    ('normalize_polynomial_features', StandardScaler()),
    ('feature_selection', RFE(LinearRegression(), verbose=1)),
    ('lin_reg', LinearRegression())
])

现在,当在网格搜索中拟合此管道时,我指定以下参数进行调整:

params = {
    'polynomial_features__degree': [1, 2, 3],
    'feature_selection__n_features_to_select': st.randint(10, 100)
}

有没有办法可以将 n_features_to_select 设置为数据集中特征总数的百分比?因为不知道PolynomialFeatures()会增加多少功能。

提前致谢,

凯文

【问题讨论】:

  • 您可以在 RFE 上创建一个包装器,将百分比转换为数字以发送到内部 RFE。

标签: python machine-learning scikit-learn pipeline rfe


【解决方案1】:

您可以将float作为step Argument you为0.0和1.0之间,默认情况下会删除每个步骤的百分比。

退房the documentation here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-10
    • 2013-08-20
    • 1970-01-01
    • 2013-03-12
    • 2011-01-08
    相关资源
    最近更新 更多