Documentation
Classes
VotingClassifier

VotingClassifier

Soft Voting/Majority Rule classifier for unfitted estimators.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new VotingClassifier(opts?: object): VotingClassifier;

Parameters

NameTypeDescription
opts?object-
opts.estimators?anyInvoking the fit method on the VotingClassifier will fit clones of those original estimators that will be stored in the class attribute self.estimators\_. An estimator can be set to 'drop' using set\_params.
opts.flatten_transform?booleanAffects shape of transform output only when voting=’soft’ If voting=’soft’ and flatten_transform=true, transform method returns matrix with shape (n_samples, n_classifiers * n_classes). If flatten_transform=false, it returns (n_classifiers, n_samples, n_classes). Default Value true
opts.n_jobs?numberThe number of jobs to run in parallel for fit. 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.verbose?booleanIf true, the time elapsed while fitting will be printed as it is completed. Default Value false
opts.voting?"hard" | "soft"If ‘hard’, uses predicted class labels for majority rule voting. Else if ‘soft’, predicts the class label based on the argmax of the sums of the predicted probabilities, which is recommended for an ensemble of well-calibrated classifiers. Default Value 'hard'
opts.weights?ArrayLikeSequence of weights (float or int) to weight the occurrences of predicted class labels (hard voting) or class probabilities before averaging (soft voting). Uses uniform weights if undefined.

Returns

VotingClassifier

Defined in: generated/ensemble/VotingClassifier.ts:23 (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/ensemble/VotingClassifier.ts:125 (opens in a new tab)

fit()

Fit the estimators.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeTraining vectors, where n\_samples is the number of samples and n\_features is the number of features.
opts.sample_weight?ArrayLikeSample weights. If undefined, then samples are equally weighted. Note that this is supported only if all underlying estimators support sample weights.
opts.y?ArrayLikeTarget values.

Returns

Promise<any>

Defined in: generated/ensemble/VotingClassifier.ts:142 (opens in a new tab)

fit_transform()

Return class labels or probabilities for each estimator.

Return predictions for X for each estimator.

Signature

fit_transform(opts: object): Promise<any[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeInput samples.
opts.fit_params?anyAdditional fit parameters.
opts.y?ArrayLikeTarget values (undefined for unsupervised transformations).

Returns

Promise<any[]>

Defined in: generated/ensemble/VotingClassifier.ts:193 (opens in a new tab)

get_feature_names_out()

Get output feature names for transformation.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.input_features?anyNot used, present here for API consistency by convention.

Returns

Promise<any>

Defined in: generated/ensemble/VotingClassifier.ts:244 (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 MetadataRequest encapsulating routing information.

Returns

Promise<any>

Defined in: generated/ensemble/VotingClassifier.ts:284 (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/ensemble/VotingClassifier.ts:77 (opens in a new tab)

predict()

Predict class labels for X.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeThe input samples.

Returns

Promise<ArrayLike>

Defined in: generated/ensemble/VotingClassifier.ts:321 (opens in a new tab)

predict_proba()

Compute probabilities of possible outcomes for samples in X.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeThe input samples.

Returns

Promise<ArrayLike[]>

Defined in: generated/ensemble/VotingClassifier.ts:356 (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/ensemble/VotingClassifier.ts:395 (opens in a new tab)

set_fit_request()

Request metadata passed to the fit 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_fit_request(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/ensemble/VotingClassifier.ts:448 (opens in a new tab)

set_output()

Set output container.

See Introducing the set_output API for an example on how to use the API.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.transform?"default" | "pandas"Configure output of transform and fit\_transform.

Returns

Promise<any>

Defined in: generated/ensemble/VotingClassifier.ts:488 (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/ensemble/VotingClassifier.ts:527 (opens in a new tab)

transform()

Return class labels or probabilities for X for each estimator.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeTraining vectors, where n\_samples is the number of samples and n\_features is the number of features.

Returns

Promise<any>

Defined in: generated/ensemble/VotingClassifier.ts:565 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/ensemble/VotingClassifier.ts:21 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/ensemble/VotingClassifier.ts:20 (opens in a new tab)

_py

PythonBridge

Defined in: generated/ensemble/VotingClassifier.ts:19 (opens in a new tab)

id

string

Defined in: generated/ensemble/VotingClassifier.ts:16 (opens in a new tab)

opts

any

Defined in: generated/ensemble/VotingClassifier.ts:17 (opens in a new tab)

Accessors

classes_

The classes labels.

Signature

classes_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/ensemble/VotingClassifier.ts:679 (opens in a new tab)

estimators_

The collection of fitted sub-estimators as defined in estimators that are not ‘drop’.

Signature

estimators_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/ensemble/VotingClassifier.ts:600 (opens in a new tab)

feature_names_in_

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

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/ensemble/VotingClassifier.ts:706 (opens in a new tab)

le_

Transformer used to encode the labels during fit and decode during prediction.

Signature

le_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/ensemble/VotingClassifier.ts:654 (opens in a new tab)

named_estimators_

Attribute to access any fitted sub-estimators by name.

Signature

named_estimators_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/ensemble/VotingClassifier.ts:627 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/ensemble/VotingClassifier.ts:64 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/ensemble/VotingClassifier.ts:68 (opens in a new tab)