samLL: Training function of Sparse Additive Logistic Regression

View source: R/samLL.R

samLLR Documentation

Training function of Sparse Additive Logistic Regression

Description

Fit a sparse additive logistic regression model on training data.

Usage

samLL(
  X,
  y,
  p = 3,
  lambda = NULL,
  nlambda = NULL,
  lambda.min.ratio = 0.1,
  thol = 1e-05,
  max.ite = 1e+05,
  regfunc = "L1"
)

Arguments

X

Numeric training matrix with n rows (samples) and d columns (features).

y

Binary training labels of length n. Labels must be coded as 0 and 1.

p

The number of basis spline functions. The default value is 3.

lambda

Optional user-supplied regularization sequence. If provided, use a decreasing sequence; warm starts are used along the path and are usually much faster than fitting a single value.

nlambda

The number of lambda values. The default value is 20.

lambda.min.ratio

Smallest lambda as a fraction of lambda.max (the smallest value that keeps all component functions at zero). The default is 0.1.

thol

Stopping tolerance. The default value is 1e-5.

max.ite

Maximum number of iterations. The default value is 1e5.

regfunc

A string indicating the regularizer. The default value is "L1". You can also assign "MCP" or "SCAD" to it.

Details

The solver combines block coordinate descent, fast iterative soft-thresholding, and Newton updates. Computation is accelerated by warm starts and active-set screening.

Value

p

The number of basis spline functions used in training.

X.min

Per-feature minimums from training data (used to rescale test data).

X.ran

Per-feature ranges from training data (used to rescale test data).

lambda

Sequence of regularization parameters used in training.

w

Solution path matrix with size d*p+1 by length(lambda); each column corresponds to one regularization parameter.

df

Degrees of freedom along the solution path (number of non-zero component functions).

knots

The p-1 by d matrix. Each column contains the knots applied to the corresponding variable.

Boundary.knots

The 2 by d matrix. Each column contains the boundary points applied to the corresponding variable.

func_norm

Functional norm matrix (d by length(lambda)); each column corresponds to one regularization parameter.

See Also

SAM,plot.samLL,print.samLL,predict.samLL

Examples


## generating training data
n = 200
d = 100
X = 0.5*matrix(runif(n*d),n,d) + matrix(rep(0.5*runif(n),d),n,d)
y = sign(((X[,1]-0.5)^2 + (X[,2]-0.5)^2)-0.06)

## flipping about 5 percent of y
y = y*sign(runif(n)-0.05)
y = sign(y==1)

## Training
out.trn = samLL(X,y)
out.trn

## plotting solution path
plot(out.trn)

## generating testing data
nt = 1000
Xt = 0.5*matrix(runif(nt*d),nt,d) + matrix(rep(0.5*runif(nt),d),nt,d)

yt = sign(((Xt[,1]-0.5)^2 + (Xt[,2]-0.5)^2)-0.06)

## flipping about 5 percent of y
yt = yt*sign(runif(nt)-0.05)
yt = sign(yt==1)

## predicting response
out.tst = predict(out.trn,Xt)

SAM documentation built on Feb. 19, 2026, 5:06 p.m.