tool
Stop
Bases: Exception
Exception raised when the tool loop should be stopped.
start_prediction_loop(model, adapter, *, adapter_to_model_transforms=None, model_to_adapter_transforms=None)
Start a prediction loop with the given model and adapter.
Source code in src/flowcean/core/tool/predict.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
test_model(model, test_data, predicate, *, show_progress=False, stop_after=1)
Test a model with the given test data and predicate.
This function runs the model on the test data and checks if the predictions satisfy the given predicate. If any prediction does not satisfy the predicate, a TestFailed exception is raised. This exception contains the input data and prediction that failed the predicate and can be used as a counterexample. This method relies on the model's predict method to obtain a prediction. It does not utilize the model's type or internal structure to prove predicates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Model
|
The model to test. |
required |
test_data
|
IncrementalEnvironment
|
The test data to use for testing the model. This must only include input features passed to the model and not the targets. |
required |
predicate
|
Predicate
|
The predicate used to check the model's predictions. |
required |
show_progress
|
bool
|
Whether to show progress during testing. Defaults to False. |
False
|
stop_after
|
int
|
Number of tests that need to fail before stopping. Defaults to 1. If set to 0 or negative, all tests are run regardless of failures. |
1
|
Raises:
Type | Description |
---|---|
TestFailed
|
If the model's prediction does not satisfy the predicate. |
Source code in src/flowcean/core/tool/test.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|