View source: R/bayesian_linear_regression_train.R
| bayesian_linear_regression_train | R Documentation |
An implementation of the Bayesian linear regression training.
bayesian_linear_regression_train(
input,
responses,
center = FALSE,
scale = FALSE,
verbose = getOption("mlpack.verbose", FALSE)
)
input |
Matrix of covariates (X) (numeric matrix). |
responses |
Matrix of responses/observations (y) (numeric row). |
center |
Center the data and fit the intercept if enabled. Default value "FALSE" (logical). |
scale |
Scale each feature by their standard deviations if enabled. Default value "FALSE" (logical). |
verbose |
Display informational messages and the full list of parameters and timers at the end of execution. Default value "getOption("mlpack.verbose", FALSE)" (logical). |
An implementation of the Bayesian linear regression. This model is a probabilistic view and implementation of the linear regression. The final solution is obtained by computing a posterior distribution from gaussian likelihood and a zero mean gaussian isotropic prior distribution on the solution. Optimization is AUTOMATIC and does not require cross validation. The optimization is performed by maximization of the evidence function. Parameters are tuned during the maximization of the marginal likelihood. This procedure includes the Ockham's razor that penalizes over complex solutions.
To train a BayesianLinearRegression model, the "input" and "responses" parameters must be given. The "center" and "scale" parameters control the centering and the normalizing options. A trained model is returned.
A list with several components defining the class attributes:
output_model |
Output BayesianLinearRegression model (BayesianLinearRegression). |
mlpack developers
#
# #' # \dontrun{
# suppressMessages(library(mlpack)) # in case 'mlpack' is not yet loaded
# X <- as.matrix(read.csv("http://datasets.mlpack.org/admission_predict.csv",
# header=FALSE))
# y <-
# as.matrix(read.csv("http://datasets.mlpack.org/admission_predict.responses.
# csv", header=FALSE))
# pp <- preprocess_split(input=X, input_label=as.matrix(1:nrow(X)),
# test_ratio=0.2)
# X_train <- pp[["training"]]
# X_test <- pp[["test"]]
# # labels are indices to operate on both factors or numeric data
# y_train <- y[as.integer(pp[["training_labels"]]), 1]
# y_test <- y[as.integer(pp[["test_labels"]]), 1]
#
# model <- bayesian_linear_regression_train(input=X_train, responses=y_train,
# center=1, scale=0)
# }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.