elasticNetFeatures: Extract Vectors of Ranked and Selected Features From an...

Description Usage Arguments Value Author(s) Examples

Description

Provides a ranking of features based on the magnitude of fitted GLM coefficients. Also provides the selected features which are those with a non-zero coefficient.

Usage

1
2
  ## S4 method for signature 'multnet'
elasticNetFeatures(model)

Arguments

model

A fitted multinomial GLM which was created by glmnet.

Value

An list object. The first element is a vector or data frame of ranked features, the second is a vector or data frame of selected features.

Author(s)

Dario Strbenac

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    if(require(glmnet))
    {
      # Genes 76 to 100 have differential expression.
      genesMatrix <- sapply(1:25, function(sample) c(rnorm(100, 9, 2)))
      genesMatrix <- cbind(genesMatrix, sapply(1:25, function(sample)
                                        c(rnorm(75, 9, 2), rnorm(25, 14, 2))))
      classes <- factor(rep(c("Poor", "Good"), each = 25))
      colnames(genesMatrix) <- paste("Sample", 1:ncol(genesMatrix))
      rownames(genesMatrix) <- paste("Gene", 1:nrow(genesMatrix))
    
      resubstituteParams <- ResubstituteParams(nFeatures = seq(10, 100, 10),
                                               performanceType = "balanced error",
                                               better = "lower")
                                             
      # alpha is a user-specified tuning parameter.
      # lambda is automatically tuned, based on glmnet defaults, if not user-specified.                 
      trainParams <- TrainParams(elasticNetGLMtrainInterface, nlambda = 500)
      predictParams <- PredictParams(elasticNetGLMpredictInterface)                           
      classified <- runTests(genesMatrix, classes, datasetName = "Example",
                             classificationName = "Differential Expression",
                             validation = "fold",
                             params = list(trainParams, predictParams))
                                        
      elasticNetFeatures(models(classified)[[1]])
    }

ClassifyR documentation built on Nov. 8, 2020, 6:53 p.m.