Stack of estimators with a final classifier.
Stacked generalization consists in stacking the output of individual estimator and use a classifier to compute the final prediction. Stacking allows to use the strength of each individual estimator by using their output as input of a final estimator.
Note that estimators\_
are fitted on the full X
while final\_estimator\_
is trained using cross-validated predictions of the base estimators using cross\_val\_predict
.
Read more in the User Guide.
new StackingClassifier(opts?: object): StackingClassifier;
Name | Type | Description |
---|---|---|
opts? |
object |
- |
opts.cv? |
number | "prefit" |
Determines the cross-validation splitting strategy used in cross\_val\_predict to train final\_estimator . Possible inputs for cv are: |
opts.estimators? |
any |
Base estimators which will be stacked together. Each element of the list is defined as a tuple of string (i.e. name) and an estimator instance. An estimator can be set to ‘drop’ using set\_params . The type of estimator is generally expected to be a classifier. However, one can pass a regressor for some use case (e.g. ordinal regression). |
opts.final_estimator? |
any |
A classifier which will be used to combine the base estimators. The default classifier is a LogisticRegression . |
opts.n_jobs? |
number |
The number of jobs to run in parallel all estimators fit . undefined means 1 unless in a joblib.parallel\_backend context. -1 means using all processors. See Glossary for more details. |
opts.passthrough? |
boolean |
When false , only the predictions of estimators will be used as training data for final\_estimator . When true , the final\_estimator is trained on the predictions as well as the original training data. Default Value false |
opts.stack_method? |
"auto" | "predict_proba" | "decision_function" | "predict" |
Methods called for each base estimator. It can be: Default Value 'auto' |
opts.verbose? |
number |
Verbosity level. Default Value 0 |
Defined in: generated/ensemble/StackingClassifier.ts:27
Decision function for samples in X
using the final estimator.
decision_function(opts: object): Promise<ArrayLike>;
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. |
Promise
<ArrayLike
>
Defined in: generated/ensemble/StackingClassifier.ts:155
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
dispose(): Promise<void>;
Promise
<void
>
Defined in: generated/ensemble/StackingClassifier.ts:138
Fit the estimators.
fit(opts: object): Promise<any>;
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. Note that y will be internally encoded in numerically increasing order or lexicographic order. If the order matter (e.g. for ordinal regression), one should numerically encode the target y before calling fit. |
Promise
<any
>
Defined in: generated/ensemble/StackingClassifier.ts:193
Fit to data, then transform it.
Fits transformer to X
and y
with optional parameters fit\_params
and returns a transformed version of X
.
fit_transform(opts: object): Promise<any[]>;
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). |
Promise
<any
[]>
Defined in: generated/ensemble/StackingClassifier.ts:244
Get output feature names for transformation.
get_feature_names_out(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.input_features? |
any |
Input features. The input feature names are only used when passthrough is true . |
Promise
<any
>
Defined in: generated/ensemble/StackingClassifier.ts:295
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
get_metadata_routing(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.routing? |
any |
A MetadataRequest encapsulating routing information. |
Promise
<any
>
Defined in: generated/ensemble/StackingClassifier.ts:335
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
init(py: PythonBridge): Promise<void>;
Name | Type |
---|---|
py |
PythonBridge |
Promise
<void
>
Defined in: generated/ensemble/StackingClassifier.ts:88
Predict target for X.
predict(opts: object): Promise<ArrayLike>;
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.predict_params? |
any |
Parameters to the predict called by the final\_estimator . Note that this may be used to return uncertainties from some estimators with return\_std or return\_cov . Be aware that it will only accounts for uncertainty in the final estimator. |
Promise
<ArrayLike
>
Defined in: generated/ensemble/StackingClassifier.ts:373
Predict class probabilities for X
using the final estimator.
predict_proba(opts: object): Promise<any[] | ArrayLike[]>;
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. |
Promise
<any
[] | ArrayLike
[]>
Defined in: generated/ensemble/StackingClassifier.ts:415
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.
score(opts: object): Promise<number>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
Test samples. |
opts.sample_weight? |
ArrayLike |
Sample weights. |
opts.y? |
ArrayLike |
True labels for X . |
Promise
<number
>
Defined in: generated/ensemble/StackingClassifier.ts:454
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:
set_fit_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.sample_weight? |
string | boolean |
Metadata routing for sample\_weight parameter in fit . |
Promise
<any
>
Defined in: generated/ensemble/StackingClassifier.ts:507
Set output container.
See Introducing the set_output API for an example on how to use the API.
set_output(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.transform? |
"default" | "pandas" |
Configure output of transform and fit\_transform . |
Promise
<any
>
Defined in: generated/ensemble/StackingClassifier.ts:547
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:
set_score_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.sample_weight? |
string | boolean |
Metadata routing for sample\_weight parameter in score . |
Promise
<any
>
Defined in: generated/ensemble/StackingClassifier.ts:586
Return class labels or probabilities for X for each estimator.
transform(opts: object): Promise<ArrayLike[]>;
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. |
Promise
<ArrayLike
[]>
Defined in: generated/ensemble/StackingClassifier.ts:624
boolean
=false
Defined in: generated/ensemble/StackingClassifier.ts:25
boolean
=false
Defined in: generated/ensemble/StackingClassifier.ts:24
PythonBridge
Defined in: generated/ensemble/StackingClassifier.ts:23
string
Defined in: generated/ensemble/StackingClassifier.ts:20
any
Defined in: generated/ensemble/StackingClassifier.ts:21
Class labels.
classes_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/ensemble/StackingClassifier.ts:659
The elements of the estimators
parameter, having been fitted on the training data. If an estimator has been set to 'drop'
, it will not appear in estimators\_
. When cv="prefit"
, estimators\_
is set to estimators
and is not fitted again.
estimators_(): Promise<any>;
Promise
<any
>
Defined in: generated/ensemble/StackingClassifier.ts:686
Names of features seen during fit. Only defined if the underlying estimators expose such an attribute when fit.
feature_names_in_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/ensemble/StackingClassifier.ts:740
The classifier which predicts given the output of estimators\_
.
final_estimator_(): Promise<any>;
Promise
<any
>
Defined in: generated/ensemble/StackingClassifier.ts:767
Attribute to access any fitted sub-estimators by name.
named_estimators_(): Promise<any>;
Promise
<any
>
Defined in: generated/ensemble/StackingClassifier.ts:713
py(): PythonBridge;
PythonBridge
Defined in: generated/ensemble/StackingClassifier.ts:75
py(pythonBridge: PythonBridge): void;
Name | Type |
---|---|
pythonBridge |
PythonBridge |
void
Defined in: generated/ensemble/StackingClassifier.ts:79
The method used by each base estimator.
stack_method_(): Promise<any>;
Promise
<any
>
Defined in: generated/ensemble/StackingClassifier.ts:794