pyshred.engine package#
Submodules#
pyshred.engine.engine module#
- class pyshred.engine.engine.SHREDEngine(data_manager: DataManager, shred_model: SHRED)[source]#
Bases:
object
High-level interface for SHRED model inference and evaluation.
- Parameters:
data_manager (DataManager) – Prepared data manager with fitted scalers.
shred_model (SHRED) – Trained SHRED model instance.
- Variables:
dm (DataManager) – The data manager for preprocessing and postprocessing.
model (SHRED) – The trained SHRED model.
- decode(latents)[source]#
Decode latent states back to full physical state space.
- Parameters:
latents (np.ndarray or torch.Tensor) – Latent representations to decode.
- Returns:
Dictionary mapping dataset IDs to reconstructed physical states.
- Return type:
dict
- evaluate(sensor_measurements: ndarray, Y: Dict[str, ndarray]) DataFrame [source]#
Performs end‐to‐end reconstruction error in the physical space.
- Parameters:
sensor_measurements ((T, n_sensors)) – The test sensor time series.
Y (dict[id] -> array (T, *spatial_shape)) – The raw full‐state ground truth for each dataset id.
- Return type:
DataFrame indexed by dataset id with columns [MSE, RMSE, MAE, R2].
- forecast_latent(h, init_latents)[source]#
Forecast future latent states using the latent forecaster.
- Parameters:
h (int) – Number of future timesteps to forecast.
init_latents (np.ndarray or torch.Tensor) – Initial latent states for seeding the forecast.
- Returns:
Forecasted latent states.
- Return type:
np.ndarray
- Raises:
RuntimeError – If no latent forecaster is available.
- sensor_to_latent(sensor_measurements: ndarray | Tensor | DataFrame) ndarray [source]#
Convert raw sensor measurements into latent-space embeddings.
- Parameters:
sensor_measurements (array-like of shape (T, n_sensors)) – Raw sensor time series.
- Returns:
latents – The GRU/LSTM final-hidden-state at each time index.
- Return type:
np.ndarray of shape (T, latent_dim)
pyshred.engine.parametric_engine module#
- class pyshred.engine.parametric_engine.ParametricSHREDEngine(data_manager: ParametricDataManager, shred_model: SHRED)[source]#
Bases:
object
High-level interface for SHRED model inference and evaluation.
- Parameters:
data_manager (ParametricDataManager) – Prepared data manager with fitted scalers.
shred_model (SHRED) – Trained SHRED model instance.
- Variables:
dm (ParametricDataManager) – The data manager for preprocessing and postprocessing.
model (SHRED) – The trained SHRED model.
- decode(latents)[source]#
Decode latent states back to full physical state space.
- Parameters:
latents (np.ndarray or torch.Tensor) – Latent representations to decode.
- Returns:
Dictionary mapping dataset IDs to reconstructed physical states.
- Return type:
dict
- evaluate(sensor_measurements: ndarray, Y: Dict[str, ndarray]) DataFrame [source]#
Performs end‐to‐end reconstruction error in the physical space.
- Parameters:
sensor_measurements ((T, n_sensors)) – The test sensor time series.
Y (dict[id] -> array (T, *spatial_shape)) – The raw full‐state ground truth for each dataset id.
- Return type:
DataFrame indexed by dataset id with columns [MSE, RMSE, MAE, R2].
- sensor_to_latent(sensor_measurements: ndarray | Tensor | DataFrame) ndarray [source]#
Convert raw sensor measurements into latent-space embeddings.
- Parameters:
sensor_measurements (array-like of shape (T, n_sensors)) – Raw sensor time series.
- Returns:
latents – The GRU/LSTM final-hidden-state at each time index.
- Return type:
np.ndarray of shape (T, latent_dim)