glmnet.model <- function(nfolds = 3,
metric = "Accuracy",
summaryFunction = defaultSummary,
preProcess = c("center", "scale", "zv"),
description = NULL, ...)
{
library(glmnet)
library(caret)
function()
{
model.name <- "glmnet"
model_ <- NULL
train_ <- function(X_train, y)
{
model_ <<- train(
x = X_train,
y = y,
method = "glmnet",
metric = metric,
preProcess = preProcess, ...,
trControl = trainControl(method = "cv",
number = nfolds,
summaryFunction = summaryFunction,
classProbs = TRUE,
returnResamp = "none",
returnData = FALSE))
browser()
invisible()
}
predict_ <- function(X_test)
{
predictions <- predict(model_, X_test, type = "prob")
predictions <- rename.prediction.columns(predictions, model.name)
predictions
}
list(
train_ = train_,
predict_ = predict_,
name = model.name,
description = description
)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.