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

Description Usage Arguments Value Examples

Description

Training by using cross validation on a linear model with square 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
LMSquareLossL2CV(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
data(ozone, package = "ElemStatLearn")
y.vec <- ozone[, 1]
X.mat <- as.matrix(ozone[,-1])
result.list <- LMSquareLossL2CV(X.mat, y.vec, NULL, penalty.vec = seq(5, 0.1, by = -0.1))
result.list$predict(X.mat[c(3,4,11),])

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