neural_lam.loss_weighting#

Utility functions for configuring state-feature loss weighting.

Functions#

get_manual_state_feature_weights(→ list[float])

Return the state feature weights as a list of floats in the order of the

get_state_feature_weighting(→ list[float])

Return the state feature weights as a list of floats in the order of the

get_uniform_state_feature_weights(→ list[float])

Return the state feature weights as a list of floats in the order of the

Module Contents#

neural_lam.loss_weighting.get_manual_state_feature_weights(weighting_config: neural_lam.config.ManualStateFeatureWeighting, datastore: neural_lam.datastore.base.BaseDatastore) → list[float][source]#

Return the state feature weights as a list of floats in the order of the state features in the datastore.

Parameters:
Returns:

List of floats containing the state feature weights.

Return type:

list[float]

Raises:

ValueError – If the set of feature names in weighting_config.weights does not match the state feature names in the datastore.

neural_lam.loss_weighting.get_state_feature_weighting(config: neural_lam.config.NeuralLAMConfig, datastore: neural_lam.datastore.base.BaseDatastore) → list[float][source]#

Return the state feature weights as a list of floats in the order of the state features in the datastore. The weights are determined based on the configuration in the NeuralLAMConfig object.

Parameters:
  • config (NeuralLAMConfig) – Configuration object for neural-lam.

  • datastore (BaseDatastore) – Datastore object containing the state features.

Returns:

List of floats containing the state feature weights.

Return type:

list[float]

Raises:

NotImplementedError – If config.training.state_feature_weighting is not a recognised weighting configuration type.

neural_lam.loss_weighting.get_uniform_state_feature_weights(datastore: neural_lam.datastore.base.BaseDatastore) → list[float][source]#

Return the state feature weights as a list of floats in the order of the state features in the datastore.

The weights are uniform, i.e. 1.0/n_features for each feature.

Parameters:

datastore (BaseDatastore) – Datastore object containing the state features.

Returns:

List of floats containing the state feature weights.

Return type:

list[float]