[R] glmnet - choosing the number of features

Steve Lianoglou mailinglist.honeypot at gmail.com
Thu Jul 8 18:44:13 CEST 2010


Hi Brian,

On Wed, Jul 7, 2010 at 10:54 PM, Brian Tsai <btsai00 at gmail.com> wrote:
> Hi,
>
> I am trying to use the glmnet package to do some simple feature selection.
>  However,  I would ideally like to be able to specify the number of features
> to return (the glmnet package, as far as I can tell, only allows
> specification of a regularization parameter, lambda, that in turn returns a
> model with a specific number of non-zero features).
>
> Is there a straightforward way of calculating the lambda value that will
> return a specific number of features? I realize there is a range of lambdas
> that should give a certain number of non-zero features, but is there an easy
> way of figuring out what this range is?

Perhaps the "dfmax" argument to the glmnet function is what you're after?

dfmax::
Limit the maximum number of variables in the model. Useful for very
large nvars, if a partial path is desired.

See ?glmnet for more information.

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



More information about the R-help mailing list