-
Notifications
You must be signed in to change notification settings - Fork 634
/
bridge.R
23 lines (23 loc) · 1.25 KB
/
bridge.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
modelInfo <- list(label = "Bayesian Ridge Regression",
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::bridge(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
},
tags = c("Linear Regression", "Bayesian Model", "L2 Regularization"),
prob = NULL,
sort = function(x) x)