DocumentationClassesOutputCodeClassifier

Class: OutputCodeClassifier

(Error-Correcting) Output-Code multiclass strategy.

Output-code based strategies consist in representing each class with a binary code (an array of 0s and 1s). At fitting time, one binary classifier per bit in the code book is fitted. At prediction time, the classifiers are used to project new points in the class space and the class closest to the points is chosen. The main advantage of these strategies is that the number of classifiers used can be controlled by the user, either for compressing the model (0 < code_size < 1) or for making the model more robust to errors (code_size > 1). See the documentation for more details.

Read more in the User Guide.

Python Reference

Constructors

new OutputCodeClassifier()

new OutputCodeClassifier(opts?): OutputCodeClassifier

Parameters

ParameterTypeDescription
opts?object-
opts.code_size?numberPercentage of the number of classes to be used to create the code book. A number between 0 and 1 will require fewer classifiers than one-vs-the-rest. A number greater than 1 will require more classifiers than one-vs-the-rest.
opts.estimator?anyAn estimator object implementing fit and one of decision_function or predict_proba.
opts.n_jobs?numberThe number of jobs to use for the computation: the multiclass 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.
opts.random_state?numberThe generator used to initialize the codebook. Pass an int for reproducible output across multiple function calls. See Glossary.

Returns OutputCodeClassifier

Defined in generated/multiclass/OutputCodeClassifier.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/multiclass/OutputCodeClassifier.ts:23
_isInitializedbooleanfalsegenerated/multiclass/OutputCodeClassifier.ts:22
_pyPythonBridgeundefinedgenerated/multiclass/OutputCodeClassifier.ts:21
idstringundefinedgenerated/multiclass/OutputCodeClassifier.ts:18
optsanyundefinedgenerated/multiclass/OutputCodeClassifier.ts:19

Accessors

classes_

Get Signature

get classes_(): Promise<ArrayLike>

Array containing labels.

Returns Promise<ArrayLike>

Defined in generated/multiclass/OutputCodeClassifier.ts:356


code_book_

Get Signature

get code_book_(): Promise<ArrayLike[]>

Binary array containing the code of each class.

Returns Promise<ArrayLike[]>

Defined in generated/multiclass/OutputCodeClassifier.ts:383


estimators_

Get Signature

get estimators_(): Promise<any>

Estimators used for predictions.

Returns Promise<any>

Defined in generated/multiclass/OutputCodeClassifier.ts:329


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

Names of features seen during fit. Only defined if the underlying estimator exposes such an attribute when fit.

Returns Promise<ArrayLike>

Defined in generated/multiclass/OutputCodeClassifier.ts:437


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit. Only defined if the underlying estimator exposes such an attribute when fit.

Returns Promise<number>

Defined in generated/multiclass/OutputCodeClassifier.ts:410


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/multiclass/OutputCodeClassifier.ts:54

Methods

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/OutputCodeClassifier.ts:110


fit()

fit(opts): Promise<any>

Fit underlying estimators.

Parameters

ParameterTypeDescription
optsobject-
opts.fit_params?anyParameters passed to the estimator.fit method of each sub-estimator.
opts.X?ArrayLikeData.
opts.y?ArrayLikeMulti-class targets.

Returns Promise<any>

Defined in generated/multiclass/OutputCodeClassifier.ts:127


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

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRouter encapsulating routing information.

Returns Promise<any>

Defined in generated/multiclass/OutputCodeClassifier.ts:173


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/multiclass/OutputCodeClassifier.ts:67


predict()

predict(opts): Promise<ArrayLike>

Predict multi-class targets using underlying estimators.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeData.

Returns Promise<ArrayLike>

Defined in generated/multiclass/OutputCodeClassifier.ts:209


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

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

Returns Promise<number>

Defined in generated/multiclass/OutputCodeClassifier.ts:245


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

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in score.

Returns Promise<any>

Defined in generated/multiclass/OutputCodeClassifier.ts:293