DocumentationClassesVotingClassifier

Class: VotingClassifier

Soft Voting/Majority Rule classifier for unfitted estimators.

Read more in the User Guide.

Python Reference

Constructors

new VotingClassifier()

new VotingClassifier(opts?): VotingClassifier

Parameters

ParameterTypeDescription
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).
opts.n_jobs?numberThe number of jobs to run in parallel for fit. undefined means 1 unless in a joblib.parallel_backend 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.
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.
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

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/ensemble/VotingClassifier.ts:21
_isInitializedbooleanfalsegenerated/ensemble/VotingClassifier.ts:20
_pyPythonBridgeundefinedgenerated/ensemble/VotingClassifier.ts:19
idstringundefinedgenerated/ensemble/VotingClassifier.ts:16
optsanyundefinedgenerated/ensemble/VotingClassifier.ts:17

Accessors

classes_

Get Signature

get classes_(): Promise<ArrayLike>

The classes labels.

Returns Promise<ArrayLike>

Defined in generated/ensemble/VotingClassifier.ts:651


estimators_

Get Signature

get estimators_(): Promise<any>

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

Returns Promise<any>

Defined in generated/ensemble/VotingClassifier.ts:572


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

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

Returns Promise<ArrayLike>

Defined in generated/ensemble/VotingClassifier.ts:678


le_

Get Signature

get le_(): Promise<any>

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

Returns Promise<any>

Defined in generated/ensemble/VotingClassifier.ts:626


named_estimators_

Get Signature

get named_estimators_(): Promise<any>

Attribute to access any fitted sub-estimators by name.

Returns Promise<any>

Defined in generated/ensemble/VotingClassifier.ts:599


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/ensemble/VotingClassifier.ts:64

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/ensemble/VotingClassifier.ts:118


fit()

fit(opts): Promise<any>

Fit the estimators.

Parameters

ParameterTypeDescription
optsobject-
opts.fit_params?anyParameters to pass to the underlying estimators.
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.X?ArrayLikeTraining vectors, where n_samples is the number of samples and n_features is the number of features.
opts.y?ArrayLikeTarget values.

Returns Promise<any>

Defined in generated/ensemble/VotingClassifier.ts:135


fit_transform()

fit_transform(opts): Promise<any[]>

Return class labels or probabilities for each estimator.

Return predictions for X for each estimator.

Parameters

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

Returns Promise<any[]>

Defined in generated/ensemble/VotingClassifier.ts:186


get_feature_names_out()

get_feature_names_out(opts): Promise<any>

Get output feature names for transformation.

Parameters

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

Returns Promise<any>

Defined in generated/ensemble/VotingClassifier.ts:232


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

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

Returns Promise<any>

Defined in generated/ensemble/VotingClassifier.ts:270


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/ensemble/VotingClassifier.ts:77


predict()

predict(opts): Promise<ArrayLike>

Predict class labels for X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeThe input samples.

Returns Promise<ArrayLike>

Defined in generated/ensemble/VotingClassifier.ts:306


predict_proba()

predict_proba(opts): Promise<ArrayLike[]>

Compute probabilities of possible outcomes for samples in X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeThe input samples.

Returns Promise<ArrayLike[]>

Defined in generated/ensemble/VotingClassifier.ts:340


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

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeSample weights.
opts.X?ArrayLike[]Test samples.
opts.y?ArrayLikeTrue labels for X.

Returns Promise<number>

Defined in generated/ensemble/VotingClassifier.ts:378


set_fit_request()

set_fit_request(opts): Promise<any>

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:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in fit.

Returns Promise<any>

Defined in generated/ensemble/VotingClassifier.ts:426


set_output()

set_output(opts): Promise<any>

Set output container.

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

Parameters

ParameterTypeDescription
optsobject-
opts.transform?"default" | "pandas" | "polars"Configure output of transform and fit_transform.

Returns Promise<any>

Defined in generated/ensemble/VotingClassifier.ts:464


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

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in score.

Returns Promise<any>

Defined in generated/ensemble/VotingClassifier.ts:502


transform()

transform(opts): Promise<any>

Return class labels or probabilities for X for each estimator.

Parameters

ParameterTypeDescription
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:538