Class: ClassifierChain
A multi-label model that arranges binary classifiers into a chain.
Each model makes a prediction in the order specified by the chain using all of the available features provided to the model plus the predictions of models that are earlier in the chain.
For an example of how to use ClassifierChain
and benefit from its ensemble, see ClassifierChain on a yeast dataset example.
Read more in the User Guide.
Constructors
new ClassifierChain()
new ClassifierChain(
opts
?):ClassifierChain
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.base_estimator ? | any | The base estimator from which the classifier chain is built. |
opts.chain_method ? | "predict_proba" | "decision_function" | "predict" | "predict_log_proba" | Prediction method to be used by estimators in the chain for the ‘prediction’ features of previous estimators in the chain. |
opts.cv ? | number | Determines whether to use cross validated predictions or true labels for the results of previous estimators in the chain. Possible inputs for cv are: |
opts.order ? | ArrayLike | "random" | If undefined , the order will be determined by the order of columns in the label matrix Y.: |
opts.random_state ? | number | If order='random' , determines random number generation for the chain order. In addition, it controls the random seed given at each base_estimator at each chaining iteration. Thus, it is only used when base_estimator exposes a random_state . Pass an int for reproducible output across multiple function calls. See Glossary. |
opts.verbose ? | boolean | If true , chain progress is output as each model is completed. |
Returns ClassifierChain
Defined in generated/multioutput/ClassifierChain.ts:27
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/multioutput/ClassifierChain.ts:25 |
_isInitialized | boolean | false | generated/multioutput/ClassifierChain.ts:24 |
_py | PythonBridge | undefined | generated/multioutput/ClassifierChain.ts:23 |
id | string | undefined | generated/multioutput/ClassifierChain.ts:20 |
opts | any | undefined | generated/multioutput/ClassifierChain.ts:21 |
Accessors
chain_method_
Get Signature
get chain_method_():
Promise
<string
>
Prediction method used by estimators in the chain for the prediction features.
Returns Promise
<string
>
Defined in generated/multioutput/ClassifierChain.ts:508
classes_
Get Signature
get classes_():
Promise
<any
[]>
A list of arrays of length len(estimators_)
containing the class labels for each estimator in the chain.
Returns Promise
<any
[]>
Defined in generated/multioutput/ClassifierChain.ts:433
estimators_
Get Signature
get estimators_():
Promise
<any
[]>
A list of clones of base_estimator.
Returns Promise
<any
[]>
Defined in generated/multioutput/ClassifierChain.ts:458
feature_names_in_
Get Signature
get feature_names_in_():
Promise
<ArrayLike
>
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Returns Promise
<ArrayLike
>
Defined in generated/multioutput/ClassifierChain.ts:558
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit. Only defined if the underlying base_estimator
exposes such an attribute when fit.
Returns Promise
<number
>
Defined in generated/multioutput/ClassifierChain.ts:533
order_
Get Signature
get order_():
Promise
<any
[]>
The order of labels in the classifier chain.
Returns Promise
<any
[]>
Defined in generated/multioutput/ClassifierChain.ts:483
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/multioutput/ClassifierChain.ts:70
Methods
decision_function()
decision_function(
opts
):Promise
<ArrayLike
[]>
Evaluate the decision_function of the models in the chain.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | The input data. |
Returns Promise
<ArrayLike
[]>
Defined in generated/multioutput/ClassifierChain.ts:139
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/multioutput/ClassifierChain.ts:122
fit()
fit(
opts
):Promise
<any
>
Fit the model to data matrix X and targets Y.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.fit_params ? | any | Parameters passed to the fit method of each step. Only available if enable_metadata_routing=True . See the User Guide. |
opts.X ? | ArrayLike | The input data. |
opts.Y ? | ArrayLike [] | The target values. |
Returns Promise
<any
>
Defined in generated/multioutput/ClassifierChain.ts:173
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/multioutput/ClassifierChain.ts:219
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/multioutput/ClassifierChain.ts:83
predict()
predict(
opts
):Promise
<ArrayLike
[]>
Predict on the data matrix X using the ClassifierChain model.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The input data. |
Returns Promise
<ArrayLike
[]>
Defined in generated/multioutput/ClassifierChain.ts:253
predict_log_proba()
predict_log_proba(
opts
):Promise
<ArrayLike
[]>
Predict logarithm of probability estimates.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The input data. |
Returns Promise
<ArrayLike
[]>
Defined in generated/multioutput/ClassifierChain.ts:285
predict_proba()
predict_proba(
opts
):Promise
<ArrayLike
[]>
Predict probability estimates.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The input data. |
Returns Promise
<ArrayLike
[]>
Defined in generated/multioutput/ClassifierChain.ts:319
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/multioutput/ClassifierChain.ts:353
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
>
Defined in generated/multioutput/ClassifierChain.ts:399