lale.lib.sklearn.stacking_classifier module

class lale.lib.sklearn.stacking_classifier.StackingClassifier(*, estimators, final_estimator=None, cv=5, stack_method='auto', n_jobs=None, passthrough=False)

Bases: PlannedIndividualOp

Stacking classifier from scikit-learn for stacking ensemble.

This documentation is auto-generated from JSON schemas.

Parameters
  • estimators (array) –

    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.

    • items : tuple

      • item 0 : string

      • item 1 : union type

        • operator

        • or None

  • final_estimator (union type, default None) –

    A classifier which will be used to combine the base estimators. The default classifier is a ‘LogisticRegression’

    • operator

    • or None

  • cv (union type, default 5) –

    Determines the cross-validation splitting strategy used in cross_val_predict to train final_estimator.

    • union type

      • integer, >=2, >=3 for optimizer, <=4 for optimizer, uniform distribution, default 5

        Number of folds for cross-validation.

      • or None, not for optimizer

        to use the default 5-fold cross validation

    • or ‘prefit’, not for optimizer

      ”prefit” to assume the estimators are prefit. In this case, the estimators will not be refitted.

    • or CrossvalGenerator, not for optimizer

      Object with split function: generator yielding (train, test) splits as arrays of indices. Can use any of the iterators from https://scikit-learn.org/stable/modules/cross_validation.html#cross-validation-iterators

  • stack_method (‘auto’, ‘predict_proba’, ‘decision_function’, or ‘predict’, not for optimizer, default ‘auto’) – Methods called for each base estimator. If ‘auto’, it will try to invoke, for each estimator, ‘predict_proba’, ‘decision_function’ or ‘predict’ in that order. Otherwise, one of ‘predict_proba’, ‘decision_function’ or ‘predict’. If the method is not implemented by the estimator, it will raise an error.

  • n_jobs (union type, not for optimizer, default None) –

    The number of jobs to run in parallel for fit.

    • integer

    • or None

  • passthrough (boolean, default False) – 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.

decision_function(X)

Confidence scores for all classes.

Note: The decision_function method is not available until this operator is trained.

Once this method is available, it will have the following signature:

Parameters

X (array of items : array of items : float) – Training vectors, where n_samples is the number of samples and n_features is the number of features.

Returns

result – The decision function computed by the final estimator.

Return type

array of items : array of items : float

fit(X, y=None, **fit_params)

Train the operator.

Note: The fit method is not available until this operator is trainable.

Once this method is available, it will have the following signature:

Parameters
  • X (array of items : array of items : float) – Training vectors, where n_samples is the number of samples and n_features is the number of features.

  • y (union type) –

    The target values (class labels).

    • array of items : float

    • or array of items : string

    • or array of items : boolean

  • sample_weight (union type, optional) –

    Sample weights. If None, then samples are equally weighted.

    • array of items : float

    • or None

predict(X, **predict_params)

Make predictions.

Note: The predict method is not available until this operator is trained.

Once this method is available, it will have the following signature:

Parameters

X (array, optional of items : array of items : float) – The input samples.

Returns

result – Predicted targets.

Return type

array of items : float

predict_proba(X)

Probability estimates for all classes.

Note: The predict_proba method is not available until this operator is trained.

Once this method is available, it will have the following signature:

Parameters

X (array, optional of items : array of items : float) – The input samples.

Returns

result – Class probabilities of the input samples.

Return type

array of items : array of items : float

transform(X, y=None)

Transform the data.

Note: The transform method is not available until this operator is trained.

Once this method is available, it will have the following signature:

Parameters

X (array, optional of items : array of items : float) – Training vectors, where n_samples is the number of samples and n_features is the number of features

Returns

result – Transformed array

  • items : array

    • items : union type

      • float

      • or array of items : float

Return type

array