pyuncertainnumber.calibration.data_peeling

Submodules

Functions

data_peeling_algorithm(→ tuple[list, list])

Data peeling algorithm for constructing a sequence of nested enclosing sets.

data_peeling_backward(→ tuple[list, list, list])

peeling_to_structure(→ tuple[numpy.typing.NDArray, list])

Peeling to structure.

uniform(lo, hi[, N])

plot_peeling(x, a, b[, p, axes3d, figsize, grid, label])

Plotting function for data peeling results.

plot_peeling_nxd(x, a, b[, fx, p, figsize, aspect, ...])

plot_peeling_nxd_back(ux, c[, p, figsize, aspect, ...])

plot_peeling_nx2(X, a, b[, p, max_level, label, grid, ...])

plot_scattermatrix(x[, bins, GS, figsize, aspect, ...])

samples_to_fuzzy_projection(→ numpy.typing.NDArray)

boxes_to_fuzzy_projection(boxes[, p])

coverage_samples(lo, hi[, m])

pickle_load(filename[, ext])

pickle_dump(x[, filename, ext, ordinal])

banana_data([n, d, seed, dist])

banana_model(x)

Package Contents

pyuncertainnumber.calibration.data_peeling.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.

Parameters:
  • X (NDArray) – data set of iid observations

  • tol (float) – a tolerance parameter determining the minimal size of an allowed enclosing box

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

Return type:

tuple[list, list]

ks_bounds

Illustration of the data peeling algorithm.

pyuncertainnumber.calibration.data_peeling.data_peeling_backward(uy: numpy.typing.NDArray, y: numpy.typing.NDArray = None, boxes: list = None, tol=0.0001) tuple[list, list, list]
Parameters:
  • uy (NDArray) – (mxd) array of coverage samples output space.

  • boxes (list) – sequence of boxes, each box is a (dx2) array. Also iterable of interval objects.

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.

Return type:

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.

pyuncertainnumber.calibration.data_peeling.peeling_to_structure(a: list, b: list, kind: str = 'scenario', beta: float = 0.01) tuple[numpy.typing.NDArray, list]

Peeling to structure.

Parameters:
  • a (list) – (number of levels long) of sets (or list) of indices of heterogeneous size

  • b (list) – (number of levels long) of (dx2) boxes (array-like)

Returns:

(lxdx2) array containing the projections of a joint fuzzy number. p: list[float] of length l

Return type:

f

Note

Note b may not be boxes, but spheres, ellipses, etc.

Tip

keep b for piping: peeling_to_structure(data_peeling_algorithm(x))

pyuncertainnumber.calibration.data_peeling.uniform(lo, hi, N=100)
pyuncertainnumber.calibration.data_peeling.plot_peeling(x: numpy.typing.NDArray, a, b, p=None, axes3d=False, figsize='medium', grid=True, label='X')

Plotting function for data peeling results.

Parameters:
  • x (NDArray) – data set of iid observations

  • a – sequence of subindices for each level

  • b – sequence of boxes or enclosing sets

  • p – upper violation probability (membership value)

pyuncertainnumber.calibration.data_peeling.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)
pyuncertainnumber.calibration.data_peeling.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)
pyuncertainnumber.calibration.data_peeling.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)
pyuncertainnumber.calibration.data_peeling.plot_scattermatrix(x, bins=10, GS=None, figsize=None, aspect='auto', color=None, marker='s', alpha=None, edgecolors='face', grid=True, label='X')
pyuncertainnumber.calibration.data_peeling.samples_to_fuzzy_projection(ux: numpy.typing.NDArray, c: list) numpy.typing.NDArray
Parameters:
  • ux (NDArray) – an (mxd_) array of samples, usually uniform. m is a large integer.

  • c (list) – 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.

Returns:

returns a d-dimensional fuzzy number, i.e. an (lxdx2) array.

Return type:

fx (NDArray)

pyuncertainnumber.calibration.data_peeling.boxes_to_fuzzy_projection(boxes: list, p: list = None)
Parameters:

boxes (list) – sequence of boxes, each box is a (dx2) array. Also iterable of interval objects. Second output of the forward data-peeling algorithm.

Returns:

an (lxdx3) fuzzy projection data structure

Return type:

f (NDArray)

pyuncertainnumber.calibration.data_peeling.coverage_samples(lo: numpy.typing.NDArray, hi: numpy.typing.NDArray, m: int = 1000)
Parameters:
  • lo (NDArray) – an (d,) array (or list) of left endpoints. Coverage means samples are generated using low-discrepancy schemes.

  • hi (NDArray) – an (d,) array (or list) of right endpoints, with hi > lo.

Returns:

an (mxd_) array of coverage samples

Return type:

u (NDArray)

pyuncertainnumber.calibration.data_peeling.pickle_load(filename: str, ext='.pickle')
pyuncertainnumber.calibration.data_peeling.pickle_dump(x: numpy.ndarray, filename: str = None, ext='.pickle', ordinal=True)
pyuncertainnumber.calibration.data_peeling.banana_data(n=100, d=2, seed: int = None, dist='normal')
pyuncertainnumber.calibration.data_peeling.banana_model(x: numpy.ndarray)