Predictors#

The Predictor uses a state estimate (type UncertainData subclass, output of a StateEstimator), information about expected future loading, and a PrognosticsModel to predict both future states (also outputs, performance metrics, event_states) at predefined points and the time that an event will occur (Time of Event, ToE) with uncertainty.

Here’s an example of its use. In this example we use the ThrownObject model and the MonteCarlo predictor, and we save the state every 1s. We also use a scalar first state (i.e., no uncertainty).

>>> from progpy.models import ThrownObject
>>> from progpy.predictors import MonteCarlo
>>> from progpy.uncertain_data import ScalarData
>>>
>>> m = ThrownObject()
>>> pred = MonteCarlo(m)
>>> first_state = ScalarData({'x': 1.7, 'v': 20})  # Initial state for prediction
>>> def future_loading(t, x):
>>>    return {}  # ThrownObject doesn't have a way of loading it
>>>
>>> pred_results = pred.predict(first_state, future_loading, save_freq=1)
>>> pred_results.time_of_event.plot_hist(events='impact')  # Plot a histogram of when the impact event occurred

See tutorial and examples for more information and additional features.

Included Predictors#

The following predictors are included with this package. A new predictor can be created by subclassing Predictor. See also: predictor_template.py

class progpy.predictors.MonteCarlo(model, **kwargs)#

Class for performing a monte-carlo model-based prediction.

A Predictor using the monte carlo algorithm. The provided initial states are simulated until either a specified time horizon is met, or the threshold for all simulated events is reached for all samples. A provided future loading equation is used to compute the inputs to the system at any given time point.

The following configuration parameters are supported (as kwargs in constructor or as parameters in predict method):

n_samplesint, optional

Default number of samples to use. If not specified, a default value is used. If state is type UnweightedSamples and n_samples is not provided, the provided unweighted samples will be used directly.

save_freqfloat, optional

Default frequency at which results are saved (s).

Predictor Interface#

class progpy.predictors.Predictor(model, **kwargs)#

Interface class for predictors

Abstract base class for creating predictors that perform prediction. Predictor subclasses must implement this interface. Equivilant to “Predictors” in NASA’s Matlab Prognostics Algorithm Library

Parameters
  • model (PrognosticsModel) –

    See: progpy package

    A prognostics model to be used in prediction

  • kwargs (optional, keyword arguments) –

abstract predict(state: progpy.uncertain_data.uncertain_data.UncertainData, future_loading_eqn: Callable, **kwargs) progpy.predictors.prediction.PredictionResults#

Perform a single prediction

Parameters
  • state (UncertainData) – Distribution representing current state of the system

  • future_loading_eqn (function (t, x) -> z) – Function to generate an estimate of loading at future time t, and state x

Returns

result from prediction, including

  • times (List[float]): Times for each savepoint such that inputs.snapshot(i), states.snapshot(i), outputs.snapshot(i), and event_states.snapshot(i) are all at times[i]

  • inputs (Prediction): Inputs at each savepoint such that inputs.snapshot(i) is the input distribution (type UncertainData) at times[i]

  • states (Prediction): States at each savepoint such that states.snapshot(i) is the state distribution (type UncertainData) at times[i]

  • outputs (Prediction): Outputs at each savepoint such that outputs.snapshot(i) is the output distribution (type UncertainData) at times[i]

  • event_states (Prediction): Event states at each savepoint such that event_states.snapshot(i) is the event state distribution (type UncertainData) at times[i]

  • time_of_event (UncertainData): Distribution of predicted Time of Event (ToE) for each predicted event, represented by some subclass of UncertaintData (e.g., MultivariateNormalDist)

Return type

NameTuple