Skip to content

truncating

A module with functions for truncating RUL data.

truncate_runs(features, targets, percent_broken=None, included_runs=None, degraded_only=False)

Truncate RUL data according to percent_broken and included_runs.

RUL data has two dimensions in which it can be truncated: the number of runs and the length of the runs. Truncating the number of runs limits the inter-run variety of the data. Truncating the length of the run limits the amount of available data near failure.

For more information about truncation, see the reader module page.

Examples:

Truncating via percent_broken

>>> import numpy as np
>>> from rul_datasets.reader.truncating import truncate_runs
>>> features = [np.random.randn(i*100, 5) for i in range(1, 6)]
>>> targets = [np.arange(i*100)[::-1] for i in range(1, 6)]
>>> (features[0].shape, targets[0].shape)
((100, 5), (100,))
>>> features, targets = truncate_runs(features, targets, percent_broken=0.8)
>>> (features[0].shape, targets[0].shape)  # runs are shorter
((80, 5), (80,))
>>> np.min(targets[0])  # runs contain no failures
20