tidy_predict.glmnet: tidy_predict.glmnet

View source: R/dCVnet_utilities.R

tidy_predict.glmnetR Documentation

tidy_predict.glmnet

Description

return a dataframe of glmnet predictions associated with outcomes (when these are provided). Standardises return over different model families.

Usage

tidy_predict.glmnet(
  mod,
  newx,
  s,
  family,
  newy = NULL,
  newoffset = NULL,
  label = "",
  binomial_thresh = 0.5,
  ...
)

Arguments

mod

a fitted glmnet object (alpha is determined by the object)

newx

new values of x for which predictions are desired.

s

the value of penalty parameter lambda at which predictions are required.

family

the glmnet model family

newy

outcome associated with newx. If provided these will be included in the output (useful for subsequent performance assessment).

newoffset

if an offset is used in the fit, then one must be supplied for making predictions.

label

an optional label (value is added in column "label")

binomial_thresh

this allows non-default thresholds to be used for classification. This is only relevant for binary classification. E.g. for an imbalanced binary outcome with 70:30 allocation, setting the decision threshold to 0.7 gives a better balance of sensitivity and specificity without requiring threshold tuning (as in AUC optimal threshold).

...

passed to predict.glmnet

Value

a data.frame containing column(s) for:

  • 'prediction' - result of predict.glmnet(.., type = "response"). The interpretation depends on the model family.

  • 'rowid' - the rownames of newx

  • 'label' - a column of a single label used when merging predictions

Optionally the data.frame will contain:

  • 'classification' - the predicted class (for nominal outcomes).

  • 'reference' - the response being predicted (if newy specified).


AndrewLawrence/dCVnet documentation built on Sept. 24, 2024, 5:24 a.m.