stepsel.binning =============== .. py:module:: stepsel.binning .. autoapi-nested-parse:: The :mod:`stepsel.binning` module includes functions for binning data. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/stepsel/binning/helper/index /autoapi/stepsel/binning/optimal/index Functions --------- .. autoapisummary:: stepsel.binning.bin_values stepsel.binning.get_tree_cut_points Package Contents ---------------- .. 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. .. 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