Class: VotingClassifier
Soft Voting/Majority Rule classifier for unfitted estimators.
Read more in the User Guide.
Constructors
new VotingClassifier()
new VotingClassifier(
opts
?):VotingClassifier
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.estimators ? | any | Invoking 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 ? | boolean | Affects 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 ? | number | The 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 ? | boolean | If 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 ? | ArrayLike | Sequence 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
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/ensemble/VotingClassifier.ts:21 |
_isInitialized | boolean | false | generated/ensemble/VotingClassifier.ts:20 |
_py | PythonBridge | undefined | generated/ensemble/VotingClassifier.ts:19 |
id | string | undefined | generated/ensemble/VotingClassifier.ts:16 |
opts | any | undefined | generated/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
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.fit_params ? | any | Parameters to pass to the underlying estimators. |
opts.sample_weight ? | ArrayLike | Sample weights. If undefined , then samples are equally weighted. Note that this is supported only if all underlying estimators support sample weights. |
opts.X ? | ArrayLike | Training vectors, where n_samples is the number of samples and n_features is the number of features. |
opts.y ? | ArrayLike | Target 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.fit_params ? | any | Additional fit parameters. |
opts.X ? | ArrayLike | Input samples. |
opts.y ? | ArrayLike | Target 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.input_features ? | any | Not 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A 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
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/ensemble/VotingClassifier.ts:77
predict()
predict(
opts
):Promise
<ArrayLike
>
Predict class labels for X.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The 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
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/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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | Training 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