LMLogisticLossL2CV: Cross validation using linear model with L2 regularization...

Description Usage Arguments Value Examples

Description

Training by using cross validation on a linear model with logistic loss and L2 regularization. Return a list which contains the best penalty, mean loss of training and validation data, and a predict function which gives a prediction based on the selected penalty.

Usage

1
LMLogisticLossL2CV(X.mat, y.vec, fold.vec, penalty.vec)

Arguments

X.mat

a numeric matrix of size [n x p]

y.vec

a numeric vector of length nrow(X.mat)

fold.vec

a numeric vector of length nrow(X.mat)

penalty.vec

a non-negative numeric vector

Value

result.list a list with mean.validation.loss.vec, mean.train.loss.vec,penalty.vec,selected.penalty,weight.vec,and predict function

Examples

1
2
3
4
5
6
data(spam, package = "ElemStatLearn")
X.mat <- as.matrix(spam[, 1:57])
y.vec <- ifelse(spam$spam == "spam", 1, 0)
penalty.vec <- seq(5,0.1, by = -0.1)
L2.list <- LMLogisticLossL2CV(X.mat, y.vec, NULL, penalty.vec)
(L2.list$predict(as.matrix(X.mat[c(2,3),])))

SixianZhang/CS499-Coding-Project-2 documentation built on May 26, 2019, 3:31 p.m.