pyuncertainnumber.calibration.data_peeling ========================================== .. py:module:: pyuncertainnumber.calibration.data_peeling Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pyuncertainnumber/calibration/data_peeling/examples/index /autoapi/pyuncertainnumber/calibration/data_peeling/fuzzy/index /autoapi/pyuncertainnumber/calibration/data_peeling/peeling/index /autoapi/pyuncertainnumber/calibration/data_peeling/plots/index /autoapi/pyuncertainnumber/calibration/data_peeling/scenario/index /autoapi/pyuncertainnumber/calibration/data_peeling/time/index Functions --------- .. autoapisummary:: pyuncertainnumber.calibration.data_peeling.data_peeling_algorithm pyuncertainnumber.calibration.data_peeling.data_peeling_backward pyuncertainnumber.calibration.data_peeling.peeling_to_structure pyuncertainnumber.calibration.data_peeling.uniform pyuncertainnumber.calibration.data_peeling.plot_peeling pyuncertainnumber.calibration.data_peeling.plot_peeling_nxd pyuncertainnumber.calibration.data_peeling.plot_peeling_nxd_back pyuncertainnumber.calibration.data_peeling.plot_peeling_nx2 pyuncertainnumber.calibration.data_peeling.plot_scattermatrix pyuncertainnumber.calibration.data_peeling.samples_to_fuzzy_projection pyuncertainnumber.calibration.data_peeling.boxes_to_fuzzy_projection pyuncertainnumber.calibration.data_peeling.coverage_samples pyuncertainnumber.calibration.data_peeling.pickle_load pyuncertainnumber.calibration.data_peeling.pickle_dump pyuncertainnumber.calibration.data_peeling.banana_data pyuncertainnumber.calibration.data_peeling.banana_model Package Contents ---------------- .. py:function:: data_peeling_algorithm(X: numpy.typing.NDArray, tol: float = 0.0001) -> tuple[list, list] Data peeling algorithm for constructing a sequence of nested enclosing sets. :param X: data set of iid observations :type X: NDArray :param tol: a tolerance parameter determining the minimal size of an allowed enclosing box :type tol: float :returns: a tuple containing: - sequence_of_indices (list): a list (number of levels long) of sets (or list) of indices of heterogeneous size - sequence_of_boxes (list): a list (number of levels long) of (dx2) boxes :rtype: tuple[list, list] .. figure:: /_static/peeling_illus.png :alt: ks_bounds :align: center :width: 90% Illustration of the data peeling algorithm. .. py:function:: data_peeling_backward(uy: numpy.typing.NDArray, y: numpy.typing.NDArray = None, boxes: list = None, tol=0.0001) -> tuple[list, list, list] :param uy: (mxd) array of coverage samples output space. :type uy: NDArray :param boxes: sequence of boxes, each box is a (dx2) array. Also iterable of interval objects. :type boxes: list :returns: a tuple containing: - a: list (number of levels long) of sets (or list) of indices (heterogeneous size). - b: list (number of levels long) of (dx2) boxes (array-like). - c: list (number of levels long) of indices (input space) conatained in each level. :rtype: tuple[list, list, list] .. note:: There are two cases where the peeling algorithm must raise an exception, and they are both linked to the termination of the algorithm. - When the last enclosing set has less samples than the minimum number of support scenarios to determine that set. - When there are enough samples to determine the set but some of them are too close to eachother (even for just one dimension). While two may be linked to the problem of degeneracy, in this context, it may be best suited to refer to this case as a coverage problem. .. py:function:: peeling_to_structure(a: list, b: list, kind: str = 'scenario', beta: float = 0.01) -> tuple[numpy.typing.NDArray, list] Peeling to structure. :param a: (number of levels long) of sets (or list) of indices of heterogeneous size :type a: list :param b: (number of levels long) of (dx2) boxes (array-like) :type b: list :returns: (lxdx2) array containing the projections of a joint fuzzy number. p: list[float] of length l :rtype: f .. note:: Note b may not be boxes, but spheres, ellipses, etc. .. tip:: keep b for piping: peeling_to_structure(data_peeling_algorithm(x)) .. py:function:: uniform(lo, hi, N=100) .. py:function:: plot_peeling(x: numpy.typing.NDArray, a, b, p=None, axes3d=False, figsize='medium', grid=True, label='X') Plotting function for data peeling results. :param x: data set of iid observations :type x: NDArray :param a: sequence of subindices for each level :param b: sequence of boxes or enclosing sets :param p: upper violation probability (membership value) .. py:function:: plot_peeling_nxd(x, a, b, fx=None, p: list = None, figsize=None, aspect='auto', label='X', marker='s', markercolor='grey', boxcolor='blue2', grid=True, baseline_alpha=0.075) .. py:function:: plot_peeling_nxd_back(ux, c, p: list = None, figsize=None, aspect='auto', xlabel='X', ylabel='$1-\\delta$', marker='s', markercolor='grey', boxcolor='blue2', colormap=None, grid=True, baseline_alpha=0.85) .. py:function:: plot_peeling_nx2(X, a, b, p: list = None, max_level: int = None, label='X', grid=True, savefig: str = None, figsize=None, baseline_alpha=0.075) .. py:function:: plot_scattermatrix(x, bins=10, GS=None, figsize=None, aspect='auto', color=None, marker='s', alpha=None, edgecolors='face', grid=True, label='X') .. py:function:: samples_to_fuzzy_projection(ux: numpy.typing.NDArray, c: list) -> numpy.typing.NDArray :param ux: an (mxd_) array of samples, usually uniform. m is a large integer. :type ux: NDArray :param c: a list (of length l) of subindices of coverage samples belonging to each level. `len(levels) < m` must yield `True`, `sum([sum(len(subi)) for subi in levels])==m` must yield `True`. :type c: list :returns: returns a d-dimensional fuzzy number, i.e. an (lxdx2) array. :rtype: fx (NDArray) .. py:function:: boxes_to_fuzzy_projection(boxes: list, p: list = None) :param boxes: sequence of boxes, each box is a (dx2) array. Also iterable of interval objects. Second output of the forward data-peeling algorithm. :type boxes: list :returns: an (lxdx3) fuzzy projection data structure :rtype: f (NDArray) .. py:function:: coverage_samples(lo: numpy.typing.NDArray, hi: numpy.typing.NDArray, m: int = 1000) :param lo: an (d,) array (or list) of left endpoints. Coverage means samples are generated using low-discrepancy schemes. :type lo: NDArray :param hi: an (d,) array (or list) of right endpoints, with hi > lo. :type hi: NDArray :returns: an (mxd_) array of coverage samples :rtype: u (NDArray) .. py:function:: pickle_load(filename: str, ext='.pickle') .. py:function:: pickle_dump(x: numpy.ndarray, filename: str = None, ext='.pickle', ordinal=True) .. py:function:: banana_data(n=100, d=2, seed: int = None, dist='normal') .. py:function:: banana_model(x: numpy.ndarray)