Bayesian Linear Regression
An implementation of the bayesian linear regression.
Available Predicates
- initModel/4
- alpha/1
- beta/1
- dataOffset/2
- dataScale/2
- omega/2
- predict/5
- predictWithStd/7
- rmse/6
- train/5
- variance/1
initModel/4
Should be called before all other predicates!
Initiates the Model so now train/5 can be called.
Before predict/5 or predictWitStd/7 can be used train/5 has to be called before
%% part of the predicate definition
initModel(+integer, +integer, +integer, +float32).
Parameters
Name | Type | Description | Default |
---|---|---|---|
centerData | +(bool)integer |
Whether or not center the data according to the examples. Set 1 (true) or 0 (false) |
(1) true |
scaleData | +(bool)integer |
Whether or not scale the data according to the standard deviation of each feature. Set 1 (true) or 0 (false) |
(0) false |
nIterMax | +integer | Maximum number of iterations for convergency. | 50 |
tol | +float | Level from which the solution is considered sufficientlly stable. | 1e-4 |
alpha/1
Get the precision (or inverse variance) of the gaussian prior.
train/5 should be called before.
%% part of the predicate definition
alpha([-integer]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
alpha | -float | Returns the alpha value | - |
beta/1
Get the precision (or inverse variance) beta of the model.
train/5 should be called before.
%% part of the predicate definition
beta([-integer]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
beta | -float | Returns the beta value | - |
dataOffset/2
Get the mean vector computed on the features over the training points.
%% part of the predicate definition
dataOffset(-integer, [-pointer(float_array)]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
responsesOffset | -vector | - | - |
dataScale/2
Get the vector of standard deviations computed on the features over the training points.
%% part of the predicate definition
dataScale(-integer, [-pointer(float_array)]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
dataOffset | -vector | - | - |
omega/2
Get the solution vector.
%% part of the predicate definition
omega(-integer, [-pointer(float_array)]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
omega | -vector | Omega solution vector | - |
predict/5
Predict yi for each data point in the given data matrix using the currently-trained Bayesian Ridge model.
%% part of the predicate definition
predict(+pointer(float_array), +integer, +integer,
-pointer(float_array), -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
points | +matrix | The data points to apply the model. | - |
predictions | -vector | y, Contains the predicted values on completion. | - |
predictWithStd/7
Predict yi 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.
%% part of the predicate definition
predictWithStd(+pointer(float_array), +integer, +integer,
-pointer(float_array), -integer,
-pointer(float_array), -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
points | +matrix | The data points to apply the model. | - |
predictions | -vector | y, Contains the predicted values on completion. | - |
std | -vector | Standard deviations of the predictions. | - |
rmse/6
Compute the Root Mean Square Error between the predictions returned by the model and the true responses.
%% part of the predicate definition
rmse(+pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
[-integer]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Data points to predict | - |
responses | +vector | A vector of targets. | - |
rmse | -float | Root mean squared error. | - |
train/5
Run BayesianLinearRegression.
The input matrix (like all mlpack matrices) should be column-major – each column is an observation and each row is a dimension.
%% part of the predicate definition
train(+pointer(float_array), +integer, +integer,
+pointer(float_array), +integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Column-major input data, dim(P, N). | - |
responses | +vector | A vector of targets, dim(N). | - |
variance/1
Get the estimate variance.
train/5 should be called before.
%% part of the predicate definition
variance([-integer]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
variance | -float | 1.0/beta | - |
Connected Links/Resources
If you want a more detailed explanation, then go to the python documentation. There is most of the time a good explanation on how the methods work and what the parameters do.
added some of the links from the python documentation