Class: OneVsOneClassifier
One-vs-one multiclass strategy.
This strategy consists in fitting one classifier per class pair. At prediction time, the class which received the most votes is selected. Since it requires to fit n_classes \* (n_classes \- 1) / 2
classifiers, this method is usually slower than one-vs-the-rest, due to its O(n_classes^2) complexity. However, this method may be advantageous for algorithms such as kernel algorithms which don’t scale well with n_samples
. This is because each individual learning problem only involves a small subset of the data whereas, with one-vs-the-rest, the complete dataset is used n_classes
times.
Read more in the User Guide.
Constructors
new OneVsOneClassifier()
new OneVsOneClassifier(
opts
?):OneVsOneClassifier
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.estimator ? | any | A regressor or a classifier that implements fit. When a classifier is passed, decision_function will be used in priority and it will fallback to predict_proba if it is not available. When a regressor is passed, predict is used. |
opts.n_jobs ? | number | The number of jobs to use for the computation: the n_classes \* ( n_classes \- 1) / 2 OVO problems are computed in parallel. undefined means 1 unless in a joblib.parallel_backend context. \-1 means using all processors. See Glossary for more details. |
Returns OneVsOneClassifier
Defined in generated/multiclass/OneVsOneClassifier.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/multiclass/OneVsOneClassifier.ts:23 |
_isInitialized | boolean | false | generated/multiclass/OneVsOneClassifier.ts:22 |
_py | PythonBridge | undefined | generated/multiclass/OneVsOneClassifier.ts:21 |
id | string | undefined | generated/multiclass/OneVsOneClassifier.ts:18 |
opts | any | undefined | generated/multiclass/OneVsOneClassifier.ts:19 |
Accessors
classes_
Get Signature
get classes_():
Promise
<any
>
Array containing labels.
Returns Promise
<any
>
Defined in generated/multiclass/OneVsOneClassifier.ts:477
estimators_
Get Signature
get estimators_():
Promise
<any
>
Estimators used for predictions.
Returns Promise
<any
>
Defined in generated/multiclass/OneVsOneClassifier.ts:450
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/multiclass/OneVsOneClassifier.ts:558
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/multiclass/OneVsOneClassifier.ts:531
pairwise_indices_
Get Signature
get pairwise_indices_():
Promise
<any
[]>
Indices of samples used when training the estimators. undefined
when estimator
’s pairwise
tag is false
.
Returns Promise
<any
[]>
Defined in generated/multiclass/OneVsOneClassifier.ts:504
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/multiclass/OneVsOneClassifier.ts:42
Methods
decision_function()
decision_function(
opts
):Promise
<ArrayLike
[]>
Decision function for the OneVsOneClassifier.
The decision values for the samples are computed by adding the normalized sum of pair-wise classification confidence levels to the votes in order to disambiguate between the decision values when the votes for all the classes are equal leading to a tie.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | Input data. |
Returns Promise
<ArrayLike
[]>
Defined in generated/multiclass/OneVsOneClassifier.ts:117
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/multiclass/OneVsOneClassifier.ts:98
fit()
fit(
opts
):Promise
<any
>
Fit underlying estimators.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.fit_params ? | any | Parameters passed to the estimator.fit method of each sub-estimator. |
opts.X ? | ArrayLike | Data. |
opts.y ? | ArrayLike | Multi-class targets. |
Returns Promise
<any
>
Defined in generated/multiclass/OneVsOneClassifier.ts:153
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/multiclass/OneVsOneClassifier.ts:199
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/multiclass/OneVsOneClassifier.ts:55
partial_fit()
partial_fit(
opts
):Promise
<any
>
Partially fit underlying estimators.
Should be used when memory is inefficient to train all data. Chunks of data can be passed in several iteration, where the first call should have an array of all target variables.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.classes ? | any | Classes across all calls to partial_fit. Can be obtained via np.unique(y_all) , where y_all is the target vector of the entire dataset. This argument is only required in the first call of partial_fit and can be omitted in the subsequent calls. |
opts.partial_fit_params ? | any | Parameters passed to the estimator.partial_fit method of each sub-estimator. |
opts.X ? | any [] | Data. |
opts.y ? | ArrayLike | Multi-class targets. |
Returns Promise
<any
>
Defined in generated/multiclass/OneVsOneClassifier.ts:237
predict()
predict(
opts
):Promise
<any
>
Estimate the best class label for each sample in X.
This is implemented as argmax(decision_function(X), axis=1)
which will return the label of the class with most votes by estimators predicting the outcome of a decision for each possible class pair.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | Data. |
Returns Promise
<any
>
Defined in generated/multiclass/OneVsOneClassifier.ts:290
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/multiclass/OneVsOneClassifier.ts:326
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/multiclass/OneVsOneClassifier.ts:374
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
>