Description Usage Arguments Details See Also Examples
Standardized interface for self-tuning regularized logistic regression.
1 | reg_logreg(x, y, folds = 5, alpha_n = 3, cost = "mse", lambda = "1se")
|
x |
Data frame with features. |
y |
Binary vector indicating outcome event. |
folds |
Number of folds to use for CV tuning |
alpha_n |
Number of alpha values to sample for CV tuning |
cost |
Cost measure to use, see |
lambda |
Decision rule to pick lambda, one of "min", "1se", "0.5se" |
Tuning is performed using cross-validation with glmnet::cv.glmnet()
.
Both lambda and alpha values are tuned. The lambda values are left to the
model default and a uniform grid of alpha values is used. The lambda value
is picked with glmnet::cv.glmnet()
's more robust 1se value (i.e. not the
absolute minimum, but closest value within 1 SD of the minimum value). Then
the globally optimum alpha value is picked.
Other Other base models:
logistic_reg_featx()
,
logistic_reg()
1 2 3 4 5 6 7 8 9 10 11 12 13 | library(modeldata)
data(credit_data)
credit_data <- credit_data[complete.cases(credit_data), ]
mdl <- reg_logreg(credit_data[, setdiff(colnames(credit_data), "Status")],
credit_data$Status,
folds = 5, alpha_n = 4)
# plots to review tuning results
plot(mdl)
plot(mdl, "alpha")
plot(mdl, "lambda")
preds <- predict(mdl, new_data = credit_data)
head(preds)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.