stepsel.binning.helper ====================== .. py:module:: stepsel.binning.helper .. autoapi-nested-parse:: Helper functions for binning. Smaller functions that are used in multiple binning functions. Functions --------- .. autoapisummary:: stepsel.binning.helper.get_tree_cut_points stepsel.binning.helper.bin_values Module Contents --------------- .. py:function:: get_tree_cut_points(clf: sklearn.tree.DecisionTreeRegressor | sklearn.tree.DecisionTreeClassifier, feature_names: numpy.typing.ArrayLike | None = None) Get the cut points of a decision tree. :param clf: The decision tree to get the cut points from. :type clf: DecisionTreeRegressor or DecisionTreeClassifier :param feature_names: The feature names of the decision tree. If None, the features are assumed to be integers. :type feature_names: array-like, optional :returns: **feature_cut_points** -- A dictionary with the feature names as keys and the cut points as values. :rtype: dict .. py:function:: bin_values(data: numpy.typing.ArrayLike, thresholds: numpy.typing.ArrayLike, right=True) -> numpy.ndarray Bin data into bins based on thresholds. :param data: The input values to be binned. :type data: array-like :param thresholds: The thresholds to use for binning, ordered from smallest to largest. :type thresholds: array-like :param right: Whether the intervals should be closed on the right (default) or left. :type right: bool, optional :returns: **binned_values** -- The binned values. String format is "(a, b]" if right=True, "[a, b)" if right=False. :rtype: array-like .. todo:: * Add option to return pd.Categorical ordered by thresholds.