Class: RidgeClassifier
Classifier using Ridge regression.
This classifier first converts the target values into {-1, 1}
and then treats the problem as a regression task (multi-output regression in the multiclass case).
Read more in the User Guide.
Constructors
new RidgeClassifier()
new RidgeClassifier(
opts
?):RidgeClassifier
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.alpha ? | number | 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 . |
opts.class_weight ? | any | Weights associated with classes in the form {class_label: weight} . If not given, all classes are supposed to have weight one. The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes \* np.bincount(y)) . |
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. If set to false, no intercept will be used in calculations (e.g. data is expected to be already centered). |
opts.max_iter ? | number | Maximum number of iterations for conjugate gradient solver. The default value is determined by scipy.sparse.linalg. |
opts.positive ? | boolean | When set to true , forces the coefficients to be positive. Only ‘lbfgs’ solver is supported in this case. |
opts.random_state ? | number | Used when solver == ‘sag’ or ‘saga’ to shuffle the data. See Glossary for details. |
opts.solver ? | "auto" | "svd" | "lsqr" | "lbfgs" | "sag" | "saga" | "cholesky" | "sparse_cg" | Solver to use in the computational routines: |
opts.tol ? | number | The precision of the solution (coef_ ) is determined by tol which specifies a different convergence criterion for each solver: |
Returns RidgeClassifier
Defined in generated/linear_model/RidgeClassifier.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/linear_model/RidgeClassifier.ts:23 |
_isInitialized | boolean | false | generated/linear_model/RidgeClassifier.ts:22 |
_py | PythonBridge | undefined | generated/linear_model/RidgeClassifier.ts:21 |
id | string | undefined | generated/linear_model/RidgeClassifier.ts:18 |
opts | any | undefined | generated/linear_model/RidgeClassifier.ts:19 |
Accessors
coef_
Get Signature
get coef_():
Promise
<ArrayLike
[]>
Coefficient of the features in the decision function.
coef_
is of shape (1, n_features) when the given problem is binary.
Returns Promise
<ArrayLike
[]>
Defined in generated/linear_model/RidgeClassifier.ts:434
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/RidgeClassifier.ts:532
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/RidgeClassifier.ts:457
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/RidgeClassifier.ts:507
n_iter_
Get Signature
get n_iter_():
Promise
<ArrayLike
>
Actual number of iterations for each target. Available only for sag and lsqr solvers. Other solvers will return undefined
.
Returns Promise
<ArrayLike
>
Defined in generated/linear_model/RidgeClassifier.ts:482
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/RidgeClassifier.ts:97
solver_
Get Signature
get solver_():
Promise
<string
>
The solver that was used at fit time by the computational routines.
Returns Promise
<string
>
Defined in generated/linear_model/RidgeClassifier.ts:557
Methods
decision_function()
decision_function(
opts
):Promise
<ArrayLike
>
Predict confidence scores for samples.
The confidence score for a sample is proportional to the signed distance of that sample to the hyperplane.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The data matrix for which we want to get the confidence scores. |
Returns Promise
<ArrayLike
>
Defined in generated/linear_model/RidgeClassifier.ts:168
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/RidgeClassifier.ts:149
fit()
fit(
opts
):Promise
<any
>
Fit Ridge classifier model.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
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. |
opts.y ? | ArrayLike | Target values. |
Returns Promise
<any
>
Defined in generated/linear_model/RidgeClassifier.ts:202
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/RidgeClassifier.ts:246
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/RidgeClassifier.ts:110
predict()
predict(
opts
):Promise
<ArrayLike
>
Predict class labels for samples in X
.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | The data matrix for which we want to predict the targets. |
Returns Promise
<ArrayLike
>
Defined in generated/linear_model/RidgeClassifier.ts:280
score()
score(
opts
):Promise
<number
>
Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample weights. |
opts.X ? | ArrayLike [] | Test samples. |
opts.y ? | ArrayLike | True labels for X . |
Returns Promise
<number
>
Defined in generated/linear_model/RidgeClassifier.ts:314
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/RidgeClassifier.ts:360
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
>