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.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new RidgeClassifier(opts?: object): RidgeClassifier;
Parameters
Name | 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 . Default Value 1 |
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. Default Value true |
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). Default Value true |
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. Default Value false |
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: Default Value 'auto' |
opts.tol? | number | Precision of the solution. Note that tol has no effect for solvers ‘svd’ and ‘cholesky’. Default Value 0.0001 |
Returns
Defined in: generated/linear_model/RidgeClassifier.ts:25 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/linear_model/RidgeClassifier.ts:23 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/linear_model/RidgeClassifier.ts:22 (opens in a new tab)
_py
PythonBridge
Defined in: generated/linear_model/RidgeClassifier.ts:21 (opens in a new tab)
id
string
Defined in: generated/linear_model/RidgeClassifier.ts:18 (opens in a new tab)
opts
any
Defined in: generated/linear_model/RidgeClassifier.ts:19 (opens in a new tab)
Accessors
coef_
Coefficient of the features in the decision function.
coef\_
is of shape (1, n_features) when the given problem is binary.
Signature
coef_(): Promise<ArrayLike[]>;
Returns
Promise
<ArrayLike
[]>
Defined in: generated/linear_model/RidgeClassifier.ts:343 (opens in a new tab)
feature_names_in_
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Signature
feature_names_in_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/linear_model/RidgeClassifier.ts:441 (opens in a new tab)
intercept_
Independent term in decision function. Set to 0.0 if fit\_intercept \= False
.
Signature
intercept_(): Promise<number | ArrayLike>;
Returns
Promise
<number
| ArrayLike
>
Defined in: generated/linear_model/RidgeClassifier.ts:366 (opens in a new tab)
n_features_in_
Number of features seen during fit.
Signature
n_features_in_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/linear_model/RidgeClassifier.ts:416 (opens in a new tab)
n_iter_
Actual number of iterations for each target. Available only for sag and lsqr solvers. Other solvers will return undefined
.
Signature
n_iter_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/linear_model/RidgeClassifier.ts:391 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/linear_model/RidgeClassifier.ts:97 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/linear_model/RidgeClassifier.ts:101 (opens in a new tab)
Methods
decision_function()
Predict confidence scores for samples.
The confidence score for a sample is proportional to the signed distance of that sample to the hyperplane.
Signature
decision_function(opts: object): Promise<ArrayLike>;
Parameters
Name | 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:177 (opens in a new tab)
dispose()
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Signature
dispose(): Promise<void>;
Returns
Promise
<void
>
Defined in: generated/linear_model/RidgeClassifier.ts:158 (opens in a new tab)
fit()
Fit Ridge classifier model.
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Training data. |
opts.sample_weight? | number | ArrayLike | Individual weights for each sample. If given a float, every sample will have the same weight. |
opts.y? | ArrayLike | Target values. |
Returns
Promise
<any
>
Defined in: generated/linear_model/RidgeClassifier.ts:212 (opens in a new tab)
init()
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Signature
init(py: PythonBridge): Promise<void>;
Parameters
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/linear_model/RidgeClassifier.ts:110 (opens in a new tab)
predict()
Predict class labels for samples in X
.
Signature
predict(opts: object): Promise<ArrayLike>;
Parameters
Name | 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:259 (opens in a new tab)
score()
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.
Signature
score(opts: object): Promise<number>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Test samples. |
opts.sample_weight? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | True labels for X . |
Returns
Promise
<number
>
Defined in: generated/linear_model/RidgeClassifier.ts:294 (opens in a new tab)