Class: PassiveAggressiveClassifier
Passive Aggressive Classifier.
Read more in the User Guide.
Constructors
new PassiveAggressiveClassifier()
new PassiveAggressiveClassifier(
opts
?):PassiveAggressiveClassifier
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.average ? | number | boolean | When set to true , computes the averaged SGD weights and stores the result in the coef_ attribute. If set to an int greater than 1, averaging will begin once the total number of samples seen reaches average. So average=10 will begin averaging after seeing 10 samples. |
opts.C ? | number | Maximum step size (regularization). Defaults to 1.0. |
opts.class_weight ? | any | Preset for the class_weight fit parameter. Weights associated with classes. 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.early_stopping ? | boolean | Whether to use early stopping to terminate training when validation score is not improving. If set to true , it will automatically set aside a stratified fraction of training data as validation and terminate training when validation score is not improving by at least tol for n_iter_no_change consecutive epochs. |
opts.fit_intercept ? | boolean | Whether the intercept should be estimated or not. If false , the data is assumed to be already centered. |
opts.loss ? | string | The loss function to be used: hinge: equivalent to PA-I in the reference paper. squared_hinge: equivalent to PA-II in the reference paper. |
opts.max_iter ? | number | The maximum number of passes over the training data (aka epochs). It only impacts the behavior in the fit method, and not the partial_fit method. |
opts.n_iter_no_change ? | number | Number of iterations with no improvement to wait before early stopping. |
opts.n_jobs ? | number | The number of CPUs to use to do the OVA (One Versus All, for multi-class problems) computation. undefined means 1 unless in a joblib.parallel_backend context. \-1 means using all processors. See Glossary for more details. |
opts.random_state ? | number | Used to shuffle the training data, when shuffle is set to true . Pass an int for reproducible output across multiple function calls. See Glossary. |
opts.shuffle ? | boolean | Whether or not the training data should be shuffled after each epoch. |
opts.tol ? | number | The stopping criterion. If it is not undefined , the iterations will stop when (loss > previous_loss - tol). |
opts.validation_fraction ? | number | The proportion of training data to set aside as validation set for early stopping. Must be between 0 and 1. Only used if early_stopping is true . |
opts.verbose ? | number | The verbosity level. |
opts.warm_start ? | boolean | When set to true , reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution. See the Glossary. Repeatedly calling fit or partial_fit when warm_start is true can result in a different solution than when calling fit a single time because of the way the data is shuffled. |
Returns PassiveAggressiveClassifier
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:23
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/linear_model/PassiveAggressiveClassifier.ts:21 |
_isInitialized | boolean | false | generated/linear_model/PassiveAggressiveClassifier.ts:20 |
_py | PythonBridge | undefined | generated/linear_model/PassiveAggressiveClassifier.ts:19 |
id | string | undefined | generated/linear_model/PassiveAggressiveClassifier.ts:16 |
opts | any | undefined | generated/linear_model/PassiveAggressiveClassifier.ts:17 |
Accessors
classes_
Get Signature
get classes_():
Promise
<ArrayLike
>
The unique classes labels.
Returns Promise
<ArrayLike
>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:789
coef_
Get Signature
get coef_():
Promise
<ArrayLike
[][]>
Weights assigned to the features.
Returns Promise
<ArrayLike
[][]>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:654
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/PassiveAggressiveClassifier.ts:735
intercept_
Get Signature
get intercept_():
Promise
<ArrayLike
[]>
Constants in decision function.
Returns Promise
<ArrayLike
[]>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:681
loss_function_
Get Signature
get loss_function_():
Promise
<any
>
Loss function used by the algorithm.
Returns Promise
<any
>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:843
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/PassiveAggressiveClassifier.ts:708
n_iter_
Get Signature
get n_iter_():
Promise
<number
>
The actual number of iterations to reach the stopping criterion. For multiclass fits, it is the maximum over every binary fit.
Returns Promise
<number
>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:762
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/PassiveAggressiveClassifier.ts:133
t_
Get Signature
get t_():
Promise
<number
>
Number of weight updates performed during training. Same as (n_iter_ \* n_samples + 1)
.
Returns Promise
<number
>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:816
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/PassiveAggressiveClassifier.ts:208
densify()
densify(
opts
):Promise
<any
>
Convert coefficient matrix to dense array format.
Converts the coef_
member (back) to a numpy.ndarray. This is the default format of coef_
and is required for fitting, so calling this method is only required on models that have previously been sparsified; otherwise, it is a no-op.
Parameters
Parameter | Type |
---|---|
opts | object |
Returns Promise
<any
>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:246
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/PassiveAggressiveClassifier.ts:189
fit()
fit(
opts
):Promise
<any
>
Fit linear model with Passive Aggressive algorithm.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.coef_init ? | ArrayLike [] | The initial coefficients to warm-start the optimization. |
opts.intercept_init ? | ArrayLike | The initial intercept to warm-start the optimization. |
opts.X ? | ArrayLike | Training data. |
opts.y ? | ArrayLike | Target values. |
Returns Promise
<any
>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:276
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/PassiveAggressiveClassifier.ts:329
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/PassiveAggressiveClassifier.ts:146
partial_fit()
partial_fit(
opts
):Promise
<any
>
Fit linear model with Passive Aggressive algorithm.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.classes ? | ArrayLike | Classes across all calls to partial_fit. Can be obtained by via np.unique(y_all) , where y_all is the target vector of the entire dataset. This argument is required for the first call to partial_fit and can be omitted in the subsequent calls. Note that y doesn’t need to contain all labels in classes . |
opts.X ? | ArrayLike | Subset of the training data. |
opts.y ? | ArrayLike | Subset of the target values. |
Returns Promise
<any
>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:365
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 get the predictions. |
Returns Promise
<ArrayLike
>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:411
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/PassiveAggressiveClassifier.ts:449
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.coef_init ? | string | boolean | Metadata routing for coef_init parameter in fit . |
opts.intercept_init ? | string | boolean | Metadata routing for intercept_init parameter in fit . |
Returns Promise
<any
>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:499
set_partial_fit_request()
set_partial_fit_request(
opts
):Promise
<any
>
Request metadata passed to the partial_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.classes ? | string | boolean | Metadata routing for classes parameter in partial_fit . |
Returns Promise
<any
>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:544
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/PassiveAggressiveClassifier.ts:584
sparsify()
sparsify(
opts
):Promise
<any
>
Convert coefficient matrix to sparse format.
Converts the coef_
member to a scipy.sparse matrix, which for L1-regularized models can be much more memory- and storage-efficient than the usual numpy.ndarray representation.
The intercept_
member is not converted.
Parameters
Parameter | Type |
---|---|
opts | object |
Returns Promise
<any
>
Defined in generated/linear_model/PassiveAggressiveClassifier.ts:624