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.
Constructors
new OutputCodeClassifier()
new OutputCodeClassifier(
opts
?):OutputCodeClassifier
Parameters
Parameter | 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. |
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 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 OutputCodeClassifier
Defined in generated/multiclass/OutputCodeClassifier.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/multiclass/OutputCodeClassifier.ts:23 |
_isInitialized | boolean | false | generated/multiclass/OutputCodeClassifier.ts:22 |
_py | PythonBridge | undefined | generated/multiclass/OutputCodeClassifier.ts:21 |
id | string | undefined | generated/multiclass/OutputCodeClassifier.ts:18 |
opts | any | undefined | generated/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
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
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
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/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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A 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
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/multiclass/OutputCodeClassifier.ts:67
predict()
predict(
opts
):Promise
<ArrayLike
>
Predict multi-class targets using underlying estimators.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | Data. |
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
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/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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in score . |
Returns Promise
<any
>