Documentation
Classes
ClassifierChain

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.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new ClassifierChain(opts?: object): ClassifierChain;

Parameters

NameTypeDescription
opts?object-
opts.base_estimator?anyThe base estimator from which the classifier chain is built.
opts.cv?numberDetermines 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?numberIf 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?booleanIf true, chain progress is output as each model is completed. Default Value false

Returns

ClassifierChain

Defined in: generated/multioutput/ClassifierChain.ts:27 (opens in a new tab)

Methods

decision_function()

Evaluate the decision_function of the models in the chain.

Signature

decision_function(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]The input data.

Returns

Promise<ArrayLike[]>

Defined in: generated/multioutput/ClassifierChain.ts:133 (opens in a new tab)

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/multioutput/ClassifierChain.ts:116 (opens in a new tab)

fit()

Fit the model to data matrix X and targets Y.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeThe input data.
opts.Y?ArrayLike[]The target values.
opts.fit_params?anyParameters passed to the fit method of each step. Only available if enable\_metadata\_routing=True. See the User Guide.

Returns

Promise<any>

Defined in: generated/multioutput/ClassifierChain.ts:168 (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

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

Returns

Promise<any>

Defined in: generated/multioutput/ClassifierChain.ts:219 (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/multioutput/ClassifierChain.ts:72 (opens in a new tab)

predict()

Predict on the data matrix X using the ClassifierChain model.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeThe input data.

Returns

Promise<ArrayLike[]>

Defined in: generated/multioutput/ClassifierChain.ts:254 (opens in a new tab)

predict_proba()

Predict probability estimates.

Signature

predict_proba(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeThe input data.

Returns

Promise<ArrayLike[]>

Defined in: generated/multioutput/ClassifierChain.ts:287 (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/multioutput/ClassifierChain.ts:322 (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

NameTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample\_weight parameter in score.

Returns

Promise<any>

Defined in: generated/multioutput/ClassifierChain.ts:373 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/multioutput/ClassifierChain.ts:25 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/multioutput/ClassifierChain.ts:24 (opens in a new tab)

_py

PythonBridge

Defined in: generated/multioutput/ClassifierChain.ts:23 (opens in a new tab)

id

string

Defined in: generated/multioutput/ClassifierChain.ts:20 (opens in a new tab)

opts

any

Defined in: generated/multioutput/ClassifierChain.ts:21 (opens in a new tab)

Accessors

classes_

A list of arrays of length len(estimators\_) containing the class labels for each estimator in the chain.

Signature

classes_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/multioutput/ClassifierChain.ts:409 (opens in a new tab)

estimators_

A list of clones of base_estimator.

Signature

estimators_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/multioutput/ClassifierChain.ts:434 (opens in a new tab)

feature_names_in_

Names of features seen during fit. Defined only when X has feature names that are all strings.

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/multioutput/ClassifierChain.ts:509 (opens in a new tab)

n_features_in_

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

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/multioutput/ClassifierChain.ts:484 (opens in a new tab)

order_

The order of labels in the classifier chain.

Signature

order_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/multioutput/ClassifierChain.ts:459 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/multioutput/ClassifierChain.ts:59 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/multioutput/ClassifierChain.ts:63 (opens in a new tab)