Class: RidgeCV
Ridge regression with built-in cross-validation.
See glossary entry for cross-validation estimator.
By default, it performs efficient Leave-One-Out Cross-Validation.
Read more in the User Guide.
Constructors
new RidgeCV()
new RidgeCV(
opts
?):RidgeCV
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.alpha_per_target ? | boolean | Flag indicating whether to optimize the alpha value (picked from the alphas parameter list) for each target separately (for multi-output settings: multiple prediction targets). When set to true , after fitting, the alpha_ attribute will contain a value for each target. When set to false , a single alpha is used for all targets. |
opts.alphas ? | ArrayLike | Array of alpha values to try. Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. Alpha corresponds to 1 / (2C) in other linear models such as LogisticRegression or LinearSVC . If using Leave-One-Out cross-validation, alphas must be strictly positive. |
opts.cv ? | number | Determines the cross-validation splitting strategy. Possible inputs for cv are: |
opts.fit_intercept ? | boolean | Whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (i.e. data is expected to be centered). |
opts.gcv_mode ? | "auto" | "svd" | "eigen" | Flag indicating which strategy to use when performing Leave-One-Out Cross-Validation. Options are: |
opts.scoring ? | string | A string (see The scoring parameter: defining model evaluation rules) or a scorer callable object / function with signature scorer(estimator, X, y) . If undefined , the negative mean squared error if cv is ‘auto’ or undefined (i.e. when using leave-one-out cross-validation), and r2 score otherwise. |
opts.store_cv_results ? | boolean | Flag indicating if the cross-validation values corresponding to each alpha should be stored in the cv_values_ attribute (see below). This flag is only compatible with cv=None (i.e. using Leave-One-Out Cross-Validation). |
opts.store_cv_values ? | boolean | Flag indicating if the cross-validation values corresponding to each alpha should be stored in the cv_values_ attribute (see below). This flag is only compatible with cv=None (i.e. using Leave-One-Out Cross-Validation). |
Returns RidgeCV
Defined in generated/linear_model/RidgeCV.ts:27
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/linear_model/RidgeCV.ts:25 |
_isInitialized | boolean | false | generated/linear_model/RidgeCV.ts:24 |
_py | PythonBridge | undefined | generated/linear_model/RidgeCV.ts:23 |
id | string | undefined | generated/linear_model/RidgeCV.ts:20 |
opts | any | undefined | generated/linear_model/RidgeCV.ts:21 |
Accessors
alpha_
Get Signature
get alpha_():
Promise
<number
|ArrayLike
>
Estimated regularization parameter, or, if alpha_per_target=True
, the estimated regularization parameter for each target.
Returns Promise
<number
| ArrayLike
>
Defined in generated/linear_model/RidgeCV.ts:444
best_score_
Get Signature
get best_score_():
Promise
<number
|ArrayLike
>
Score of base estimator with best alpha, or, if alpha_per_target=True
, a score for each target.
Returns Promise
<number
| ArrayLike
>
Defined in generated/linear_model/RidgeCV.ts:466
coef_
Get Signature
get coef_():
Promise
<ArrayLike
>
Weight vector(s).
Returns Promise
<ArrayLike
>
Defined in generated/linear_model/RidgeCV.ts:399
cv_results_
Get Signature
get cv_results_():
Promise
<ArrayLike
[]>
Cross-validation values for each alpha (only available if store_cv_results=True
and cv=None
). After fit()
has been called, this attribute will contain the mean squared errors if scoring is None
otherwise it will contain standardized per point prediction values.
Returns Promise
<ArrayLike
[]>
Defined in generated/linear_model/RidgeCV.ts:376
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/RidgeCV.ts:514
intercept_
Get Signature
get intercept_():
Promise
<number
|ArrayLike
>
Independent term in decision function. Set to 0.0 if fit_intercept \= False
.
Returns Promise
<number
| ArrayLike
>
Defined in generated/linear_model/RidgeCV.ts:421
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/RidgeCV.ts:489
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/RidgeCV.ts:80
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/RidgeCV.ts:131
fit()
fit(
opts
):Promise
<any
>
Fit Ridge regression model with cv.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.params ? | any | Parameters to be passed to the underlying scorer. |
opts.sample_weight ? | number | ArrayLike | Individual weights for each sample. If given a float, every sample will have the same weight. |
opts.X ? | ArrayLike [] | Training data. If using GCV, will be cast to float64 if necessary. |
opts.y ? | ArrayLike | Target values. Will be cast to X’s dtype if necessary. |
Returns Promise
<any
>
Defined in generated/linear_model/RidgeCV.ts:148
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 MetadataRouter encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/linear_model/RidgeCV.ts:197
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/RidgeCV.ts:93
predict()
predict(
opts
):Promise
<any
>
Predict using the linear model.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | any | Samples. |
Returns Promise
<any
>
Defined in generated/linear_model/RidgeCV.ts:229
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/RidgeCV.ts:262
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/RidgeCV.ts:308
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/RidgeCV.ts:344