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
Name | 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). Default Value true |
opts.n_jobs? | number | The 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? | boolean | If 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? | 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
Defined in: generated/ensemble/VotingClassifier.ts:23 (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:556 (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:477 (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:583 (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:531 (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:504 (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
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/ensemble/VotingClassifier.ts:68 (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
Name | 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. |
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.y? | ArrayLike | Target 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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Input samples. |
opts.fit_params? | any | Additional fit parameters. |
opts.y? | ArrayLike | Target 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
Name | 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:244 (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
Name | Type |
---|---|
py | PythonBridge |
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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The input samples. |
Returns
Promise
<ArrayLike
>
Defined in: generated/ensemble/VotingClassifier.ts:282 (opens in a new tab)
predict_proba()
Compute probabilities of possible outcomes for samples in X.
Signature
predict_proba(opts: object): Promise<ArrayLike[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The input samples. |
Returns
Promise
<ArrayLike
[]>
Defined in: generated/ensemble/VotingClassifier.ts:317 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Test samples. |
opts.sample_weight? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | True labels for X . |
Returns
Promise
<number
>
Defined in: generated/ensemble/VotingClassifier.ts:356 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.transform? | "default" | "pandas" | Configure output of transform and fit\_transform . |
Returns
Promise
<any
>
Defined in: generated/ensemble/VotingClassifier.ts:407 (opens in a new tab)
transform()
Return class labels or probabilities for X for each estimator.
Signature
transform(opts: object): Promise<any>;
Parameters
Name | 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:442 (opens in a new tab)