|
| BayesianLinearRegression (const bool centerData=true, const bool scaleData=false, const size_t maxIterations=50, const double tolerance=1e-4) |
| Set the parameters of Bayesian Ridge regression object. More...
|
|
double | Train (const arma::mat &data, const arma::rowvec &responses) |
| Run BayesianLinearRegression. More...
|
|
void | Predict (const arma::mat &points, arma::rowvec &predictions) const |
| Predict \(y_{i}\) for each data point in the given data matrix using the currently-trained Bayesian Ridge model. More...
|
|
void | Predict (const arma::mat &points, arma::rowvec &predictions, arma::rowvec &std) const |
| Predict \(y_{i}\) and the standard deviation of the predictive posterior distribution for each data point in the given data matrix, using the currently-trained Bayesian Ridge estimator. More...
|
|
double | RMSE (const arma::mat &data, const arma::rowvec &responses) const |
| Compute the Root Mean Square Error between the predictions returned by the model and the true responses. More...
|
|
const arma::colvec & | Omega () const |
| Get the solution vector. More...
|
|
double | Alpha () const |
| Get the precision (or inverse variance) of the gaussian prior. More...
|
|
double | Beta () const |
| Get the precision (or inverse variance) beta of the model. More...
|
|
double | Variance () const |
| Get the estimated variance. More...
|
|
const arma::colvec & | DataOffset () const |
| Get the mean vector computed on the features over the training points. More...
|
|
const arma::colvec & | DataScale () const |
| Get the vector of standard deviations computed on the features over the training points. More...
|
|
double | ResponsesOffset () const |
| Get the mean value of the train responses. More...
|
|
bool | CenterData () const |
| Get whether the data will be centered during training.
|
|
bool & | CenterData () |
| Modify whether the data will be centered during training.
|
|
bool | ScaleData () const |
| Get whether the data will be scaled by standard deviations during training. More...
|
|
bool & | ScaleData () |
| Modify whether the data will be scaled by standard deviations during training. More...
|
|
size_t | MaxIterations () const |
| Get the maximum number of iterations for training.
|
|
size_t & | MaxIterations () |
| Modify the maximum number of iterations for training.
|
|
double | Tolerance () const |
| Get the tolerance for training to converge.
|
|
double & | Tolerance () |
| Modify the tolerance for training to converge.
|
|
template<typename Archive > |
void | serialize (Archive &ar, const uint32_t version) |
| Serialize the BayesianLinearRegression model. More...
|
|
A Bayesian approach to the maximum likelihood estimation of the parameters \( \omega \) of the linear regression model.
The Complexity is governed by the addition of a gaussian isotropic prior of precision \( \alpha \) over \( \omega \):
\[ p(\omega|\alpha) = \mathcal{N}(\omega|0, \alpha^{-1}I) \]
The optimization procedure calculates the posterior distribution of \( \omega \) knowing the data by maximizing an approximation of the log marginal likelihood derived from a type II maximum likelihood approximation. The determination of \( alpha \) and of the noise precision \( beta \) is part of the optimization process, leading to an automatic determination of w. The model being entirely based on probabilty distributions, uncertainties are available and easly computed for both the parameters and the predictions.
The advantage over linear regression and ridge regression is that the regularization is determined from all the training data alone without any require to an hold out method.
The code below is an implementation of the maximization of the evidence function described in the section 3.5.2 of the C.Bishop book, Pattern Recognition and Machine Learning.
@article{MacKay91bayesianinterpolation,
author = {David J.C. MacKay},
title = {Bayesian Interpolation},
journal = {NEURAL COMPUTATION},
year = {1991},
volume = {4},
pages = {415--447}
}
@book{Bishop:2006:PRM:1162264,
author = {Bishop, Christopher M.},
title = {Pattern Recognition and Machine Learning (Information Science
and Statistics)},
chapter = {3}
year = {2006},
isbn = {0387310738},
publisher = {Springer-Verlag},
address = {Berlin, Heidelberg},
}
Example of use:
arma::mat xTrain;
arma::rowvec yTrain;
estimator.Train(xTrain, yTrain);
arma::mat xTest;
arma::rowvec predictions;
estimator.Predict(xTest, prediction);
arma::rowvec yTest;
estimator.RMSE(xTest, yTest);
arma::rowvec stds;
estimator.Predict(xTest, responses, stds)