dpg.sklearn_normalizer ====================== .. py:module:: dpg.sklearn_normalizer .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: dpg.sklearn_normalizer.SklearnEnsembleNormalizer Module Contents --------------- .. py:class:: SklearnEnsembleNormalizer 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. .. py:attribute:: GB_MODELS .. py:method:: needs_normalization(model) :staticmethod: Check if a model needs tree structure normalization. :param model: sklearn ensemble model :returns: True if normalization needed :rtype: bool .. py:method:: normalize(model) :staticmethod: 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 :param model: sklearn ensemble model :returns: Normalized shallow copy with DPG-specific metadata :rtype: model .. py:method:: get_tree_class_index(model, tree_index) :staticmethod: Return the preserved class-slot index for a normalized GB tree.