Documentation
Classes
OutputCodeClassifier

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 (opens in a new tab)

Constructors

constructor()

Signature

new OutputCodeClassifier(opts?: object): OutputCodeClassifier;

Parameters

NameTypeDescription
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. Default Value 1.5
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 (opens in a new tab) 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 (opens in a new tab)

Properties

_isDisposed

boolean = false

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

_isInitialized

boolean = false

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

_py

PythonBridge

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

id

string

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

opts

any

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

Accessors

classes_

Array containing labels.

Signature

classes_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/multiclass/OutputCodeClassifier.ts:285 (opens in a new tab)

code_book_

Binary array containing the code of each class.

Signature

code_book_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/multiclass/OutputCodeClassifier.ts:312 (opens in a new tab)

estimators_

Estimators used for predictions.

Signature

estimators_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/multiclass/OutputCodeClassifier.ts:258 (opens in a new tab)

feature_names_in_

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

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/multiclass/OutputCodeClassifier.ts:366 (opens in a new tab)

n_features_in_

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

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/multiclass/OutputCodeClassifier.ts:339 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/multiclass/OutputCodeClassifier.ts:54 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/multiclass/OutputCodeClassifier.ts:58 (opens in a new tab)

Methods

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/OutputCodeClassifier.ts:113 (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/OutputCodeClassifier.ts:130 (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/OutputCodeClassifier.ts:67 (opens in a new tab)

predict()

Predict multi-class targets using underlying estimators.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeData.

Returns

Promise<ArrayLike>

Defined in: generated/multiclass/OutputCodeClassifier.ts:172 (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/OutputCodeClassifier.ts:209 (opens in a new tab)