Documentation
Classes
OneVsOneClassifier

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.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new OneVsOneClassifier(opts?: object): OneVsOneClassifier;

Parameters

NameTypeDescription
opts?object-
opts.estimator?anyA 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?numberThe 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 (opens in a new tab) context. \-1 means using all processors. See Glossary for more details.

Returns

OneVsOneClassifier

Defined in: generated/multiclass/OneVsOneClassifier.ts:25 (opens in a new tab)

Methods

decision_function()

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.

Signature

decision_function(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Input data.

Returns

Promise<ArrayLike[]>

Defined in: generated/multiclass/OneVsOneClassifier.ts:118 (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/multiclass/OneVsOneClassifier.ts:99 (opens in a new tab)

fit()

Fit underlying estimators.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeData.
opts.y?ArrayLikeMulti-class targets.

Returns

Promise<any>

Defined in: generated/multiclass/OneVsOneClassifier.ts:156 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns

Promise<any>

Defined in: generated/multiclass/OneVsOneClassifier.ts:200 (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

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/multiclass/OneVsOneClassifier.ts:55 (opens in a new tab)

partial_fit()

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.

Signature

partial_fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?any[]Data.
opts.classes?anyClasses 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.y?ArrayLikeMulti-class targets.

Returns

Promise<any>

Defined in: generated/multiclass/OneVsOneClassifier.ts:240 (opens in a new tab)

predict()

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.

Signature

predict(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeData.

Returns

Promise<any>

Defined in: generated/multiclass/OneVsOneClassifier.ts:293 (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

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Test samples.
opts.sample_weight?ArrayLikeSample weights.
opts.y?ArrayLikeTrue labels for X.

Returns

Promise<number>

Defined in: generated/multiclass/OneVsOneClassifier.ts:330 (opens in a new tab)

set_partial_fit_request()

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:

Signature

set_partial_fit_request(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.classes?string | booleanMetadata routing for classes parameter in partial\_fit.

Returns

Promise<any>

Defined in: generated/multiclass/OneVsOneClassifier.ts:383 (opens in a new tab)

set_score_request()

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:

Signature

set_score_request(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample\_weight parameter in score.

Returns

Promise<any>

Defined in: generated/multiclass/OneVsOneClassifier.ts:425 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/multiclass/OneVsOneClassifier.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/multiclass/OneVsOneClassifier.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/multiclass/OneVsOneClassifier.ts:21 (opens in a new tab)

id

string

Defined in: generated/multiclass/OneVsOneClassifier.ts:18 (opens in a new tab)

opts

any

Defined in: generated/multiclass/OneVsOneClassifier.ts:19 (opens in a new tab)

Accessors

classes_

Array containing labels.

Signature

classes_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/multiclass/OneVsOneClassifier.ts:490 (opens in a new tab)

estimators_

Estimators used for predictions.

Signature

estimators_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/multiclass/OneVsOneClassifier.ts:463 (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/multiclass/OneVsOneClassifier.ts:571 (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/multiclass/OneVsOneClassifier.ts:544 (opens in a new tab)

pairwise_indices_

Indices of samples used when training the estimators. undefined when estimator’s pairwise tag is false.

Signature

pairwise_indices_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/multiclass/OneVsOneClassifier.ts:517 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/multiclass/OneVsOneClassifier.ts:42 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/multiclass/OneVsOneClassifier.ts:46 (opens in a new tab)