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
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.code_size? | number | Percentage 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? | any | An estimator object implementing fit and one of decision_function or predict_proba. |
opts.n_jobs? | number | The 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? | number | The generator used to initialize the codebook. Pass an int for reproducible output across multiple function calls. See Glossary. |
Returns
Defined in: generated/multiclass/OutputCodeClassifier.ts:25 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Data. |
opts.y? | ArrayLike | Multi-class targets. |
Returns
Promise
<any
>
Defined in: generated/multiclass/OutputCodeClassifier.ts:130 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.routing? | any | A MetadataRequest encapsulating routing information. |
Returns
Promise
<any
>
Defined in: generated/multiclass/OutputCodeClassifier.ts:174 (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
Name | Type |
---|---|
py | PythonBridge |
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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Data. |
Returns
Promise
<ArrayLike
>
Defined in: generated/multiclass/OutputCodeClassifier.ts:212 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Test samples. |
opts.sample_weight? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | True labels for X . |
Returns
Promise
<number
>
Defined in: generated/multiclass/OutputCodeClassifier.ts:249 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight? | string | boolean | Metadata routing for sample\_weight parameter in score . |
Returns
Promise
<any
>
Defined in: generated/multiclass/OutputCodeClassifier.ts:302 (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:367 (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:394 (opens in a new tab)
estimators_
Estimators used for predictions.
Signature
estimators_(): Promise<any>;
Returns
Promise
<any
>
Defined in: generated/multiclass/OutputCodeClassifier.ts:340 (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:448 (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:421 (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
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/multiclass/OutputCodeClassifier.ts:58 (opens in a new tab)