% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrap_glmnet.R
\name{wrap_glmnet}
\alias{wrap_glmnet}
\alias{predict.wrap_glmnet}
\alias{print.wrap_glmnet}
\title{S3 wrapper for glmnet}
\usage{
wrap_glmnet(x, y, ...)

\method{predict}{wrap_glmnet}(object, newx, type = c("class", "prob"), s = NULL, ...)

\method{print}{wrap_glmnet}(x, ...)
}
\arguments{
\item{x}{A matrix or data.frame of features.}

\item{y}{A factor or character vector for classification, numeric for regression.}

\item{...}{Additional arguments passed to [glmnet::glmnet()].
Pass `family = "binomial"` for binary classification.}

\item{object}{A fitted `wrap_glmnet` object.}

\item{newx}{A matrix or data.frame of new observations.}

\item{type}{`"class"` (default) for class labels, `"prob"` for a probability
matrix. Ignored for regression.}

\item{s}{Lambda value for prediction. Defaults to the midpoint of the
lambda path. Pass `s = cv_fit$lambda.min` if using [glmnet::cv.glmnet()].}
}
\value{
An object of class `wrap_glmnet` with fields:
  \item{fit}{The fitted glmnet model.}
  \item{levels}{Class levels (NULL for regression).}
  \item{task}{"classification" or "regression".}
}
\description{
Fits a `glmnet` penalized regression model with a consistent
interface. Supports regression and binary classification.
}
\note{
Multiclass (`family = "multinomial"`) is not yet supported.
  For lambda selection, a specific `s` value can be passed to `predict()`.
  By default the midpoint of the lambda path is used. For optimal lambda,
  use [glmnet::cv.glmnet()] externally and pass `s = fit$lambda.min`.
}
\examples{

X <- iris[iris$Species != "virginica", 1:4]
y <- droplevels(iris[iris$Species != "virginica", "Species"])
mod <- wrap_glmnet(X, y, family = "binomial")
predict(mod, newx = X, type = "class")
predict(mod, newx = X, type = "prob")


X <- iris[iris$Species != "virginica", 1:4]
y <- droplevels(iris[iris$Species != "virginica", "Species"])
mod <- wrap_glmnet(X, y, family = "binomial")
predict(mod, newx = X, type = "class")
predict(mod, newx = X, type = "prob")

}
