dpg.sklearn_normalizer#

Normalizer for scikit-learn ensemble models.

Handles differences in tree storage between RandomForest, GradientBoosting, AdaBoost, and other ensemble methods to provide a consistent interface for DPG.

Classes#

SklearnEnsembleNormalizer

Normalizes sklearn ensemble models to have consistent tree access interface.

Module Contents#

class dpg.sklearn_normalizer.SklearnEnsembleNormalizer[source]#

Normalizes sklearn ensemble models to have consistent tree access interface.

Problem: Different ensemble methods store trees differently: - RandomForest: estimators_ is 1D list of DecisionTree objects - GradientBoosting: estimators_ is 2D (n_estimators, n_trees_per_iteration) - AdaBoost: estimators_ is 1D list of DecisionTree objects

Solution: Normalize to 1D list for consistent access.

GB_MODELS#
static needs_normalization(model)[source]#

Check if a model needs tree structure normalization.

Parameters:

model – sklearn ensemble model

Returns:

True if normalization needed

Return type:

bool

static normalize(model)[source]#

Normalize a sklearn ensemble model’s tree structure.

For GradientBoosting models: - Converts 2D estimators_ to 1D list - Preserves the class-slot index for multiclass classifiers

Parameters:

model – sklearn ensemble model

Returns:

Normalized shallow copy with DPG-specific metadata

Return type:

model

static get_tree_class_index(model, tree_index)[source]#

Return the preserved class-slot index for a normalized GB tree.