Scikit-Learn
42
lambda_
: float
This attribute provides the estimated precision of
the weight.
n_iter_
: int
It provides the actual number of iterations taken
by the algorithm to reach the stopping criterion.
sigma_
: array, shape = (n_features,
n_features)
It provides the estimated
variance-covariance
matrix of the weights.
scores_
: array, shape = (n_iter_+1)
It provides the value of the log marginal likelihood
at each iteration of the optimisation. In the
resulting score, the array starts with the value of
the log marginal likelihood obtained for the initial
values of
𝛼 𝑎𝑛𝑑 𝜆
, and ends with the value obtained
for estimated
𝛼 𝑎𝑛𝑑 𝜆
.
Implementation Example
Following Python script provides a simple example of fitting Bayesian Ridge Regression
model using sklearn
BayesianRidge
module.
from sklearn import linear_model
X = [[0, 0], [1, 1], [2, 2], [3, 3]]
Y = [0, 1, 2, 3]
BayReg = linear_model.BayesianRidge()
BayReg.fit(X, Y)
Output
BayesianRidge(alpha_1=1e-06, alpha_2=1e-06, compute_score=False, copy_X=True,
fit_intercept=True, lambda_1=1e-06, lambda_2=1e-06, n_iter=300,
normalize=False, tol=0.001, verbose=False)
From
the above output, we can check model’s parameters used in the calculation.
Now, once fitted, the model can predict new values as follows:
BayReg.predict([[1,1]])
Dostları ilə paylaş: