yobx.sklearn.imblearn.balanced_bagging#
- yobx.sklearn.imblearn.balanced_bagging.sklearn_balanced_bagging_classifier(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: BalancedBaggingClassifier, X: str, name: str = 'balanced_bagging_classifier') str | Tuple[str, str][source]#
Converts an
imblearn.ensemble.BalancedBaggingClassifierinto ONNX.BalancedBaggingClassifieris a bagging ensemble where each sub-estimator is trained on a balanced bootstrap sample (obtained via 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_areimblearn.pipeline.Pipelineinstances wrapping a resampler and a classifier. This converter dispatches to the registered converter forimblearn.pipeline.Pipeline(defined inyobx.sklearn.imblearn.easy_ensemble), 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 onlyestimator – a fitted
BalancedBaggingClassifierX – name of the input tensor
name – prefix used for names of nodes added by this converter
- Returns:
label tensor name, or tuple
(label, probabilities)