memilio.surrogatemodel.ode_secir_simple.model
Functions
|
Calculates the mean absolute percentage error based on the test dataset. |
|
Initialize model from given list of parameters |
|
Training and evaluation of a given model under given training parameters. |
|
Plot prediction of the model and label for one compartment. |
|
Plotting the losses of the model training. |
|
Split data set in training, validation and testing data sets. |
- memilio.surrogatemodel.ode_secir_simple.model.get_test_statistic(
- test_inputs,
- test_labels,
- model,
Calculates the mean absolute percentage error based on the test dataset.
- Parameters:
test_inputs – inputs from test data.
test_labels – labels (output) from test data.
model – trained model.
- Returns:
Dataframe with the corresponding MAPEs of the different compartments
- memilio.surrogatemodel.ode_secir_simple.model.initialize_model(parameters)
Initialize model from given list of parameters
- Parameters:
parameters – tuple of parameters describing the model architecture, it should be of the form (num_days_per_output, num_outputs, num_hidden_layers, neurons_per_layer, name_activation, name_architecture)
- Returns:
tensor flow keras model with the given architecture
- memilio.surrogatemodel.ode_secir_simple.model.network_fit(
- model,
- inputs,
- labels,
- training_parameter,
- plot=True,
Training and evaluation of a given model under given training parameters.
- Parameters:
model – Keras sequential model.
inputs – Input data used for training
labels – Output data (labels) used for training
training_parameter – tuple of parameters used for the training process, it should be of the form (early_stop, max_epochs, loss, optimizer, metrics), where loss is a loss-function implemented in keras, optimizer is the name of the used optimizer, metrics is a list of used training metrics, e.g. [tf.keras.metrics.MeanAbsoluteError(), tf.keras.metrics.MeanAbsolutePercentageError()]
plot – Default: True]
- Returns:
trained model with training history (output of model.fit())
- memilio.surrogatemodel.ode_secir_simple.model.plot_compartment_prediction_model(
- inputs,
- labels,
- model=None,
- plot_compartment='InfectedSymptoms',
- max_subplots=8,
Plot prediction of the model and label for one compartment.
If model is none, we just plot the inputs and labels for the selected compartment without any predictions. Plots are saved in directory ./plots/evaluation_secir_simple_{compartment}.png
- Parameters:
inputs – test inputs for model prediction.
labels – test labels.
model – Default: None] trained model.
plot_col – string name of compartment to be plotted,
max_subplots – Default: 8] Number of the simulation runs to be plotted and compared against.
plot_compartment – possible compartment names “Susceptible”, “Exposed”, “InfectedNoSymptoms”, “InfectedSevere”, “InfectedCritical”, “Recovered”, “Dead”
- memilio.surrogatemodel.ode_secir_simple.model.plot_losses(history)
Plotting the losses of the model training.
- Parameters:
history – model training history.
- memilio.surrogatemodel.ode_secir_simple.model.split_data(
- inputs,
- labels,
- split_train=0.7,
- split_valid=0.2,
- split_test=0.1,
Split data set in training, validation and testing data sets.
- Parameters:
inputs – input dataset
labels – label dataset
split_train – Share of training data sets. (Default value = 0.7)
split_valid – Share of validation data sets. (Default value = 0.2)
split_test – Share of testing data sets. (Default value = 0.1)
- Returns:
dictionary of the form {‘train_inputs’, ‘train_labels’, ‘valid_inputs’, ‘valid_labels’, ‘test_inputs’, ‘test_labels’}