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.
Constructors
new BayesianRidge()
new BayesianRidge(
opts
?):BayesianRidge
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.alpha_1 ? | number | Hyper-parameter : shape parameter for the Gamma distribution prior over the alpha parameter. |
opts.alpha_2 ? | number | Hyper-parameter : inverse scale parameter (rate parameter) for the Gamma distribution prior over the alpha parameter. |
opts.alpha_init ? | number | Initial value for alpha (precision of the noise). If not set, alpha_init is 1/Var(y). |
opts.compute_score ? | boolean | If true , compute the log marginal likelihood at each iteration of the optimization. |
opts.copy_X ? | boolean | If true , X will be copied; else, it may be overwritten. |
opts.fit_intercept ? | boolean | Whether 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 ? | number | Hyper-parameter : shape parameter for the Gamma distribution prior over the lambda parameter. |
opts.lambda_2 ? | number | Hyper-parameter : inverse scale parameter (rate parameter) for the Gamma distribution prior over the lambda parameter. |
opts.lambda_init ? | number | Initial value for lambda (precision of the weights). If not set, lambda_init is 1. |
opts.max_iter ? | number | Maximum number of iterations over the complete dataset before stopping independently of any early stopping criterion. |
opts.tol ? | number | Stop the algorithm if w has converged. |
opts.verbose ? | boolean | Verbose mode when fitting the model. |
Returns BayesianRidge
Defined in generated/linear_model/BayesianRidge.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/linear_model/BayesianRidge.ts:23 |
_isInitialized | boolean | false | generated/linear_model/BayesianRidge.ts:22 |
_py | PythonBridge | undefined | generated/linear_model/BayesianRidge.ts:21 |
id | string | undefined | generated/linear_model/BayesianRidge.ts:18 |
opts | any | undefined | generated/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
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Individual weights for each sample. |
opts.X ? | ArrayLike [] | Training data. |
opts.y ? | ArrayLike | Target 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A 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
Parameter | Type |
---|---|
py | PythonBridge |
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.return_std ? | boolean | Whether to return the standard deviation of posterior prediction. |
opts.X ? | ArrayLike | Samples. |
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample 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 ? | ArrayLike | True 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.return_std ? | string | boolean | Metadata 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in score . |
Returns Promise
<any
>
Defined in generated/linear_model/BayesianRidge.ts:420