Permalink
Cannot retrieve contributors at this time
24 lines (24 sloc)
1.63 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
caret/models/files/blassoAveraged.R
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modelInfo <- list(label = "Bayesian Ridge Regression (Model Averaged)", | |
library = "monomvn", | |
type = "Regression", | |
parameters = data.frame(parameter = "parameter", | |
class = "character", | |
label = "parameter"), | |
grid = function(x, y, len = NULL, search = "grid") data.frame(parameter = "none"), | |
fit = function(x, y, wts, param, lev, last, classProbs, ...) { | |
out <- monomvn::blasso(as.matrix(x), y, ...) | |
out | |
}, | |
predict = function(modelFit, newdata, submodels = NULL) { | |
if(!is.matrix(newdata)) newdata <- as.matrix(newdata) | |
out <- modelFit$beta %*% t(newdata) | |
if(modelFit$icept) out <- out + (matrix(1, ncol = ncol(out), nrow = nrow(out)) * modelFit$mu) | |
apply(out, 2, mean) | |
}, | |
predictors = function(x, s = NULL, ...) { | |
x$xNames[apply(x$beta, 2, function(x) any(x != 0))] | |
}, | |
notes = "This model makes predictions by averaging the predictions based on the posterior estimates of the regression coefficients. While it is possible that some of these posterior estimates are zero for non-informative predictors, the final predicted value may be a function of many (or even all) predictors. ", | |
tags = c("Linear Regression", "Bayesian Model", "L1 Regularization"), | |
prob = NULL, | |
sort = function(x) x) |