Skip to content

BayesianLinearRegression

Bayesian linear regression.

An advantage of Bayesian linear regression over standard linear regression is that features do not have to scaled beforehand. Another attractive property is that this flavor of linear regression is somewhat insensitive to its hyperparameters. Finally, this model can output instead a predictive distribution rather than just a point estimate.

The downside is that the learning step runs in O(n^2) time, whereas the learning step of standard linear regression takes O(n) time.

Parameters

  • alpha

    Default1

    Prior parameter.

  • beta

    Default1

    Noise parameter.

Examples

from river import datasets
from river import evaluate
from river import linear_model
from river import metrics

dataset = datasets.TrumpApproval()
model = linear_model.BayesianLinearRegression()
metric = metrics.MAE()

evaluate.progressive_val_score(dataset, model, metric).get()
0.5818

x, _ = next(iter(dataset))
model.predict_one(x)
43.61

model.predict_one(x, with_dist=True)
𝒩(μ=43.616, σ=1.003)

Methods

learn_one

Fits to a set of features x and a real-valued target y.

Parameters

  • x'dict'
  • y'base.typing.RegTarget'

Returns

Regressor: self

predict_one

Predict the output of features x.

Parameters

  • x'dict'
  • with_dist — defaults to False

Returns

base.typing.RegTarget: The prediction.