LinearModelL1: Linear Model algorithm with L1 regularization

Description Usage Arguments Value Examples

Description

This algorithm takes one penalty value

Usage

1
2
LinearModelL1(X.scaled.mat, y.vec, penalty = 0.5, opt.thresh = 0.5,
  initial.weight.vec = rnorm(ncol(X.scaled.mat) + 1), step.size = 0.01)

Arguments

X.scaled.mat

the scaled trainning input matrix (n x p)

y.vec

the training training labels with size (n x 1)

penalty

a non-neagtive numeric scalar, default value 0.5, usually does not work :)

opt.thresh

a numeric scalar, default value as 0.5

initial.weight.vec

initial weight with size (p+1 x 1), default value as a normal distribution warm up.

step.size

a numeric scalar, default value as 0.01

Value

optimal weight vector (with p+1 elements, first element is the bias/intercept b) for the given penalty parameter.

Examples

1
2
3
4
5
6
7
library(LinearModelL1)
data(prostate, package = "ElemStatLearn")
prostate <- list(features = as.matrix(prostate[, 1:8]), labels = prostate$lpsa, is.01 = FALSE)
data.set <- prostate
X.mat <- data.set$features
y.vec <- data.set$labels
LinearModelL1(X.mat,y.vec,0.2,0.1,rnorm(ncol(X.mat)+1),0.1)

SixianZhang/CS499-Coding-Project-4 documentation built on June 1, 2019, 4:58 a.m.