【问题标题】:How to deactivate embedded feature selection in caret package?如何停用插入符号包中的嵌入式功能选择?
【发布时间】:2019-07-17 03:20:52
【问题描述】:

我正在使用 R 中的 caret 包编写机器学习代码。代码示例可以是

weighted_fit <- train(outcome,
                          data = train,
                          method = 'glmnet',
                          trControl = ctrl)

如您所知,caret 包中的某些方法具有内置的特征选择,例如弹性网。我的问题是,有什么方法可以停用此代码中的内置功能选择?

提前感谢您的任何评论。

【问题讨论】:

    标签: r feature-selection


    【解决方案1】:
    #I will try to answer this question to the best of my ability:
    #The train function in caret package comes with a parameter tuneGrid which can be used to create a data-frame of tuning parameters.
    
    #The tuning parameter of elastic net regularization in glmnet() is alpha, so create the following:
    glmgrid <- expand.grid(alpha = 0) will give ridge regularization.
    glmgrid <- expand.grid(alpha = 1) will give lasso regularization.
    
    #and then use 
    
    weighted_fit <- train(outcome,
                              data = train,
                              method = 'glmnet',
                              trControl = ctrl,
                              tuneGrid = glmgrid)
    
    #In glmnet in r , the alpha values can be in the range [0,1] i.e. 0 to 1 including 0 and 1.
    
    
    # GLMNET - https://www.rdocumentation.org/packages/glmnet/versions/2.0-18/topics/glmnet
    # CARET - https://topepo.github.io/caret/index.html
    

    【讨论】:

      猜你喜欢
      • 2019-06-28
      • 2019-11-28
      • 2017-05-08
      • 2018-09-23
      • 2016-04-26
      • 2015-04-11
      • 2016-08-30
      • 1970-01-01
      • 2014-02-01
      相关资源
      最近更新 更多