Learn R Programming

mlpack (version 4.8.0)

bayesian_linear_regression_train: BayesianLinearRegression Training

Description

An implementation of the Bayesian linear regression training.

Usage

bayesian_linear_regression_train(
  input,
  responses,
  center = FALSE,
  scale = FALSE,
  verbose = getOption("mlpack.verbose", FALSE)
)

Value

A list with several components defining the class attributes:

output_model

Output BayesianLinearRegression model (BayesianLinearRegression).

Arguments

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).

Author

mlpack developers

Details

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.

Examples

Run this code
# 
# #' # \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)
#   }

Run the code above in your browser using DataLab