predict.L0Learn {L0Learn} | R Documentation |
Predict Response
Description
Predicts the response for a given sample.
Usage
## S3 method for class 'L0Learn'
predict(object, newx, lambda = NULL, gamma = NULL, ...)
## S3 method for class 'L0LearnCV'
predict(object, newx, lambda = NULL, gamma = NULL, ...)
Arguments
object |
The output of L0Learn.fit or L0Learn.cvfit |
newx |
A matrix on which predictions are made. The matrix should have p columns. |
lambda |
The value of lambda to use for prediction. A summary of the lambdas in the regularization
path can be obtained using |
gamma |
The value of gamma to use for prediction. A summary of the gammas in the regularization
path can be obtained using |
... |
ignore |
Value
A Matrix of class dgeMatrix
, which contains the model
predictions. If both lambda and gamma are not supplied, then a matrix of
predictions 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.
In case of logistic regression, probability values are returned.
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)
# Apply the fitted model with lambda=2.45513e-02 and gamma=0.0001 on X to predict the response
predict(fit, newx = X, lambda=2.45513e-02, gamma=0.0001)
# Apply the fitted model on X to predict the response for all the solutions in the path
predict(fit, newx = X)