trainLLRC: 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
trainLLRC(truthLabels, predictors, lossMat, weight = rep(1, NROW(predictors)),
  alphaVec = seq(0, 1, by = 0.2), tauVec = seq(0.1, 0.9, by = 0.1),
  naFilter = 0.6, cvFolds = 5, seed = 1, verbose = FALSE)

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

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

Arguments

truthLabels

the factor/character regression response variable

predictors

a 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 candiate tau threshold values for the logistic regression classifier

naFilter

the proportion of data for a given predictor (column) that isn't NA, if there is too many NAs then predictor is dropped

cvFolds

the number of cross validation folds

seed

set the random seed for sampling during cross validation

verbose

set to TRUE to receive intermittent messages about progress of training algorithm

glmnetGLRobject

Fix

...

Additional arguments to methods (ignored)

glmnetGLRobject

an elastic net logistic regression model

newdata

a new set of observations to be assigned a class label. This is the data one wants to predict.

...

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 trainLLRC().

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 and 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 <- trainLLRC(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.