Class: BayesianRidge

Bayesian ridge regression.

Fit a Bayesian ridge model. See the Notes section for details on this implementation and the optimization of the regularization parameters lambda (precision of the weights) and alpha (precision of the noise).

Read more in the User Guide. For an intuitive visualization of how the sinusoid is approximated by a polynomial using different pairs of initial values, see Curve Fitting with Bayesian Ridge Regression.

Python Reference

Constructors

new BayesianRidge()

new BayesianRidge(opts?): BayesianRidge

Parameters

ParameterTypeDescription
opts?object-
opts.alpha_1?numberHyper-parameter : shape parameter for the Gamma distribution prior over the alpha parameter.
opts.alpha_2?numberHyper-parameter : inverse scale parameter (rate parameter) for the Gamma distribution prior over the alpha parameter.
opts.alpha_init?numberInitial value for alpha (precision of the noise). If not set, alpha_init is 1/Var(y).
opts.compute_score?booleanIf true, compute the log marginal likelihood at each iteration of the optimization.
opts.copy_X?booleanIf true, X will be copied; else, it may be overwritten.
opts.fit_intercept?booleanWhether to calculate the intercept for this model. The intercept is not treated as a probabilistic parameter and thus has no associated variance. If set to false, no intercept will be used in calculations (i.e. data is expected to be centered).
opts.lambda_1?numberHyper-parameter : shape parameter for the Gamma distribution prior over the lambda parameter.
opts.lambda_2?numberHyper-parameter : inverse scale parameter (rate parameter) for the Gamma distribution prior over the lambda parameter.
opts.lambda_init?numberInitial value for lambda (precision of the weights). If not set, lambda_init is 1.
opts.max_iter?numberMaximum number of iterations over the complete dataset before stopping independently of any early stopping criterion.
opts.tol?numberStop the algorithm if w has converged.
opts.verbose?booleanVerbose mode when fitting the model.

Returns BayesianRidge

Defined in generated/linear_model/BayesianRidge.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/linear_model/BayesianRidge.ts:23
_isInitializedbooleanfalsegenerated/linear_model/BayesianRidge.ts:22
_pyPythonBridgeundefinedgenerated/linear_model/BayesianRidge.ts:21
idstringundefinedgenerated/linear_model/BayesianRidge.ts:18
optsanyundefinedgenerated/linear_model/BayesianRidge.ts:19

Accessors

alpha_

Get Signature

get alpha_(): Promise<number>

Estimated precision of the noise.

Returns Promise<number>

Defined in generated/linear_model/BayesianRidge.ts:502


coef_

Get Signature

get coef_(): Promise<ArrayLike>

Coefficients of the regression model (mean of distribution)

Returns Promise<ArrayLike>

Defined in generated/linear_model/BayesianRidge.ts:454


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

Names of features seen during fit. Defined only when X has feature names that are all strings.

Returns Promise<ArrayLike>

Defined in generated/linear_model/BayesianRidge.ts:692


intercept_

Get Signature

get intercept_(): Promise<number>

Independent term in decision function. Set to 0.0 if fit_intercept \= False.

Returns Promise<number>

Defined in generated/linear_model/BayesianRidge.ts:477


lambda_

Get Signature

get lambda_(): Promise<number>

Estimated precision of the weights.

Returns Promise<number>

Defined in generated/linear_model/BayesianRidge.ts:525


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/linear_model/BayesianRidge.ts:667


n_iter_

Get Signature

get n_iter_(): Promise<number>

The actual number of iterations to reach the stopping criterion.

Returns Promise<number>

Defined in generated/linear_model/BayesianRidge.ts:594


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/linear_model/BayesianRidge.ts:110


scores_

Get Signature

get scores_(): Promise<ArrayLike>

If computed_score is true, value of the log marginal likelihood (to be maximized) at each iteration of the optimization. The array starts with the value of the log marginal likelihood obtained for the initial values of alpha and lambda and ends with the value obtained for the estimated alpha and lambda.

Returns Promise<ArrayLike>

Defined in generated/linear_model/BayesianRidge.ts:571


sigma_

Get Signature

get sigma_(): Promise<ArrayLike[]>

Estimated variance-covariance matrix of the weights

Returns Promise<ArrayLike[]>

Defined in generated/linear_model/BayesianRidge.ts:548


X_offset_

Get Signature

get X_offset_(): Promise<ArrayLike>

If fit_intercept=True, offset subtracted for centering data to a zero mean. Set to np.zeros(n_features) otherwise.

Returns Promise<ArrayLike>

Defined in generated/linear_model/BayesianRidge.ts:617


X_scale_

Get Signature

get X_scale_(): Promise<ArrayLike>

Set to np.ones(n_features).

Returns Promise<ArrayLike>

Defined in generated/linear_model/BayesianRidge.ts:642

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/linear_model/BayesianRidge.ts:162


fit()

fit(opts): Promise<any>

Fit the model.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeIndividual weights for each sample.
opts.X?ArrayLike[]Training data.
opts.y?ArrayLikeTarget values. Will be cast to X’s dtype if necessary.

Returns Promise<any>

Defined in generated/linear_model/BayesianRidge.ts:179


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns Promise<any>

Defined in generated/linear_model/BayesianRidge.ts:223


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/linear_model/BayesianRidge.ts:123


predict()

predict(opts): Promise<ArrayLike>

Predict using the linear model.

In addition to the mean of the predictive distribution, also its standard deviation can be returned.

Parameters

ParameterTypeDescription
optsobject-
opts.return_std?booleanWhether to return the standard deviation of posterior prediction.
opts.X?ArrayLikeSamples.

Returns Promise<ArrayLike>

Defined in generated/linear_model/BayesianRidge.ts:259


score()

score(opts): Promise<number>

Return the coefficient of determination of the prediction.

The coefficient of determination \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true \- y_pred)\*\* 2).sum() and \(v\) is the total sum of squares ((y_true \- y_true.mean()) \*\* 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeSample weights.
opts.X?ArrayLike[]Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.
opts.y?ArrayLikeTrue values for X.

Returns Promise<number>

Defined in generated/linear_model/BayesianRidge.ts:300


set_fit_request()

set_fit_request(opts): Promise<any>

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in fit.

Returns Promise<any>

Defined in generated/linear_model/BayesianRidge.ts:346


set_predict_request()

set_predict_request(opts): Promise<any>

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.return_std?string | booleanMetadata routing for return_std parameter in predict.

Returns Promise<any>

Defined in generated/linear_model/BayesianRidge.ts:382


set_score_request()

set_score_request(opts): Promise<any>

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in score.

Returns Promise<any>

Defined in generated/linear_model/BayesianRidge.ts:420