Sensor Fusion

Core

class tsipy.fusion.core.FusionModel
class tsipy.fusion.core.NormalizeAndClip(normalization=True, clipping=True)

Normalizes and clips data in the first dimension.

Normalization enables easier and more stable learning of the GP.

Clipping discards outliers, which could disturb the learning process.

clip_by_y_values(x, y)

Discards indices where y is far from the mean.

Return type

Tuple[ndarray, ndarray]

compute_normalization_values(x, y)

Computes normalization values given x and y.

Return type

None

denormalize_y(y, y_shift=None, y_scale=None)

Denormalizes

Return type

ndarray

normalize_and_clip(x, y)

Normalizes and clips inputs.

Return type

Tuple[ndarray, ndarray]

reset()

Reset computed normalization values.

Return type

None

Kernels

Module implements custom kernels for multi-sensor fusion.

class tsipy.fusion.kernels.MultiWhiteKernel(labels, variances=None, active_dims=None)

Covariance function simulating Gaussian measurement noise.

Each sensor has its own learnable noise variance parameter. Kernel returns a noise variance for a given sensor label (integer), i.e. if the n-th measurement was made by i-th instrument, it returns \(\sigma_i^2\) as given by:

\[k(x_n, x_m) = \delta(n, m) \cdot \sigma_i^2,\]

where \(\delta(\cdot, \cdot)\) is the Kronecker delta function and \(\sigma_i^2\) is the variance of the i-th sensor measurement noise.

Implementation is based on the following guidelines

GP Models

class tsipy.fusion.models_gp.SVGPModel(kernel, num_inducing_pts=1000, inducing_trainable=False, normalization=True, clipping=True)

Local GP

tsipy.fusion.windows.create_prediction_windows(x, pred_window_width, verbose=False)

Computes bounds of prediction windows.

Returns:

A list of (x_start, x_end, x_mid) triplets corresponding to the prediction window bounds and window center.

Return type

List[Tuple[float, float, float]]

class tsipy.fusion.local_gp.LocalGPModel(model, pred_window_width, fit_window_width, normalization=True, clipping=True)

Fusion Utilities

tsipy.fusion.utils.build_and_concat_label_mask(x, label)

Builds a 1D label mask and concatenates it to x.

Examples:
>>> import numpy as np
>>> a = np.array([0, 1, 2, 4])
>>> build_and_concat_label_mask(a, label=1)
array([[0, 1],
       [1, 1],
       [2, 1],
       [4, 1]])
>>> b = np.array([[0, 1, 2, 4]])
>>> build_and_concat_label_mask(a, label=2)
array([[0, 2],
       [1, 2],
       [2, 2],
       [4, 2]])
>>> c = np.array([[0, 1], [2, 4]])
>>> build_and_concat_label_mask(c, label=3)
array([[0, 1, 3],
       [2, 4, 3]])
Returns:

2D array with concatenated label mask.

Return type

ndarray

tsipy.fusion.utils.build_and_concat_label_mask_output(x)

Builds a 1D label mask and concatenates it to x. Output label is always -1.

Examples:
>>> import numpy as np
>>> a = np.array([0, 1, 2, 4])
>>> build_and_concat_label_mask_output(a)
array([[ 0, -1],
       [ 1, -1],
       [ 2, -1],
       [ 4, -1]])
Returns:

2D array with concatenated label mask.

Return type

ndarray