eulerpi.core.model_check module

Check a custom BaseModel for implementation errors or test them in a quick inference run on an artificially created dataset.

basic_model_check(model: BaseModel) None[source]

Perform a simple sanity check on the model.

It tests the following:

  • The model has a positive parameter dimension

  • The model has a positive data dimension

  • The model has a valid combination of parameter and data dimension

  • The central parameter has the correct shape

  • The parameter limits have the correct shape

  • The model can be instantiated

  • The model forward pass can be calculated

  • The model jacobi matrix can be calculated

  • The return values of the forward pass and the jacobi matrix have the correct shape

  • The jacobi matrix has full rank

Parameters:

model (BaseModel) – The model describing the mapping from parameters to data.

Raises:

AssertionError – Raised if any of the tests fails.

Returns:

None

Examples:

from eulerpi.examples.corona import Corona
from eulerpi.core.model_check import basic_model_check

basic_model_check(Corona())
full_model_check(model: BaseModel, num_data_points: int = 1000, num_model_evaluations: int = 11000) None[source]

Perform all available checks on the model.

Check your model for basic functionality and in a quick inference run on an artificially created dataset. We recommend to run this function for every new model you create. It runs the functions basic_model_check and inference_model_check to perform the checks.

Parameters:
  • model (BaseModel) – The model describing the mapping from parameters to data.

  • num_data_points (int, optional) – The number of data data points to artificially generate (Default value = 1000)

  • num_model_evaluations (int, optional) – The number of model evaluations to perform in the inference. (Default value = 11000)

Raises:

AssertionError – Raised if any of the tests fails.

Returns:

None

Examples:

from eulerpi.examples.corona import Corona
from eulerpi.core.model_check import full_model_check

full_model_check(Corona())
inference_model_check(model: BaseModel, num_data_points: int = 1000, num_model_evaluations: int = 11000) None[source]

Check your model in a quick inference run on an artificially created dataset.

It produces a violin plot comparing the artificially created parameters and data to the respectively inferred samples.

Parameters:
  • model (BaseModel) – The model describing the mapping from parameters to data.

  • num_data_points (int, optional) – The number of data data points to artificially generate (Default value = 1000)

  • num_model_evaluations (int, optional) – The number of model evaluations to perform in the inference. (Default value = 11000)

Returns:

None

Examples:

from eulerpi.examples.corona import Corona
from eulerpi.core.model_check import inference_model_check

inference_model_check(Corona())