coef.L0Learn: Extract Solutions

View source: R/coef.R

coef.L0LearnR Documentation

Extract Solutions

Description

Extracts a specific solution in the regularization path.

Usage

## S3 method for class 'L0Learn'
coef(object, lambda = NULL, gamma = NULL, ...)

## S3 method for class 'L0LearnCV'
coef(object, lambda = NULL, gamma = NULL, ...)

Arguments

object

The output of L0Learn.fit or L0Learn.cvfit

lambda

The value of lambda at which to extract the solution.

gamma

The value of gamma at which to extract the solution.

...

ignore

Value

A sparse Matrix of class dgCMatrix, which contains the model coefficients. If both lambda and gamma are not supplied, then a matrix of coefficients for all the solutions in the regularization path is returned. If lambda is supplied but gamma is not, the smallest value of gamma is used.

Examples

# Generate synthetic data for this example
data <- GenSynthetic(n=100,p=20,k=10,seed=1)
X = data$X
y = data$y

# Fit an L0L2 Model with 3 values of Gamma ranging from 0.0001 to 10, using coordinate descent
fit <- L0Learn.fit(X, y, penalty="L0L2", nGamma=3, gammaMin=0.0001, gammaMax = 10)
print(fit)
# Extract the coefficients of the solution at lambda = 2.45513e-02 and gamma = 0.0001
coef(fit, lambda=2.45513e-02, gamma=0.0001)
# Extract the coefficients of all the solutions in the path
coef(fit)


L0Learn documentation built on March 7, 2023, 8:18 p.m.