trainGLR: Train an elastic net logistic regression classifier

Description Usage Arguments Value Author(s) Examples

Description

Train an elastic net logistic regression classifier

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
trainGLR(truthLabels, predictors, lossMat, weight = rep(1, NROW(predictors)),
  alphaVec = seq(0, 1, by = 0.2), tauVec = seq(0.1, 0.9, by = 0.05),
  naFilter = 0.6, cvFolds = 5, seed = 1, verbose = FALSE)

## S3 method for class 'glmnetGLR'
print(glmnetGLRobject, ...)

## S3 method for class 'glmnetGLR'
predict(glmnetGLRobject, newdata, truthCol = NULL,
  keepCols = NULL)

Arguments

truthLabels

the factor/character regression response variable

predictors

matrix whose columns are the explanatory regression variables

lossMat

a loss matrix specifying the penalties for classification errors

weight

the observation weights. The default value is 1 for each observation. Refer to glmnet for further information

alphaVec

The elastic net mixing parameter. Refer to glmnet for further information.

tauVec

A sequence of tau threshold values for the logistic regression classifier.

naFilter

the proportion of data for a given predictor (column) that does not consist of missing data. If the proportion of sample observations which are NA > naFilter, then those predictors are removed from the regression analysis.

cvFolds

the number of cross validation folds

seed

the random seed for sampling during cross validation

verbose

set to TRUE to receive messages regarding the progress of the training algorithm.

glmnetGLRobject

a train elastic net logistic classifier

...

Additional arguments to methods (ignored)

glmnetGLRobject

a trained elastic net logistic regression classifier

newdata

the new set of observations to be predicted. New data must be an array with the same column names as the training data

...

Additional arguments to predict method of glmnet objects are ignored, as we use the optimal values of lambda, tau, and alpha that were generated by trainGLR().

Value

The elastic net logistic regression model that minimized the expected loss over the set of alpha, lambda, and tau parameters.

Author(s)

Landon Sego

Alex Venzin

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
26
27
28
29
30
31
32
33
# Load the VOrbitrap Shewanella QC data
data(traindata)

# Here we select the predictor variables
predictors <- as.matrix(traindata[,9:96])

# The logistic regression model requires a binary response
# variable.
resp <- traindata[,"response"]

# Specify the loss matrix. The "Poor" class is the target of interest.
# The penalty for misclassifying a "Poor" item as "Good" results in a
# loss of 5.

lM <- lossMatrix(c("Good","Good","Poor","Poor"),
                c("Good","Poor","Good","Poor"),
                c(     0,     1,     5,     0))

# Train the elastic net classifier
elasticNet <- trainGLR(truthLabels = resp,
                       predictors = predictors,
                       lossMat = lM)

# Observe the optimal alpha, lambda, and tau values that produced
# this elastic net logistic regression classifier.
print(elasticNet)

# Load the new observations
data(testdata)

# Use an elastic net regression classifier to make predictions about
# new observations for the response variable.
predict(elasticNet, testdata)

PNNL-Comp-Mass-Spec/glmnetGLR documentation built on May 28, 2019, 2:23 p.m.