yobx.sklearn.imblearn.easy_ensemble#

yobx.sklearn.imblearn.easy_ensemble.imblearn_pipeline(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: Pipeline, X: str, name: str = 'imblearn_pipeline') str | Tuple[str, ...][source]#

Converts an imblearn.pipeline.Pipeline into ONNX.

At inference time, imblearn.pipeline.Pipeline skips all resampling steps (those exposing a fit_resample method) and applies only the transformers and the final estimator, identical to sklearn.pipeline.Pipeline over the filtered step list.

Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes and types defined by scikit-learn

  • outputs – desired output tensor names for the pipeline result

  • estimator – a fitted imblearn.pipeline.Pipeline

  • X – name of the input tensor

  • name – prefix used for names of nodes added by this converter

Returns:

name of the output tensor, or a tuple of output tensor names

yobx.sklearn.imblearn.easy_ensemble.sklearn_easy_ensemble_classifier(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: EasyEnsembleClassifier, X: str, name: str = 'easy_ensemble_classifier') str | Tuple[str, str][source]#

Converts an imblearn.ensemble.EasyEnsembleClassifier into ONNX.

EasyEnsembleClassifier is an ensemble of AdaBoost learners each trained on a different balanced bootstrap sample (obtained by random under-sampling). At inference time, the resampling step is inactive; each sub-estimator is therefore effectively a plain classifier.

Probabilities from all sub-estimators are averaged (soft aggregation) and the winning class is determined by an argmax over the averaged probability vector. Each sub-estimator is applied to the feature subset recorded in estimators_features_ (all features by default).

The sub-estimators stored in estimators_ are imblearn.pipeline.Pipeline instances wrapping a resampler and a classifier. This converter calls imblearn_pipeline() for each of them, which transparently drops the resampler at inference time.

Graph structure (two sub-estimators as an example):

X ──Gather(cols_0)──[sub-pipeline 0]──► (_, proba_0) (N, C)
X ──Gather(cols_1)──[sub-pipeline 1]──► (_, proba_1) (N, C)
        Unsqueeze(axis=0) ──► proba_0 (1, N, C), proba_1 (1, N, C)
            Concat(axis=0) ──► stacked (E, N, C)
                ReduceMean(axis=0) ──► avg_proba (N, C)
                    ArgMax(axis=1) ──Cast──Gather(classes_) ──► label
Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes and types defined by scikit-learn

  • outputs – desired output tensor names; two entries for (label, probabilities), one entry for label only

  • estimator – a fitted EasyEnsembleClassifier

  • X – name of the input tensor

  • name – prefix used for names of nodes added by this converter

Returns:

label tensor name, or tuple (label, probabilities)