|
| 1 | +# FlaSH System |
| 2 | + |
| 3 | +THIS README IS IN PROGRESS |
| 4 | + |
| 5 | +FlaSH is a real-time point-outlier detection system. We add the daily evaluation step to this indicators package (retraining is done offline). |
| 6 | + |
| 7 | +FlaSH produces a list of data points that are unusual or surprising so that stakeholders are aware of points that warrant further inspection. |
| 8 | + |
| 9 | +The guiding principles for the system are: |
| 10 | +- Flag relevant data points as soon as possible (ideally in an online setting) |
| 11 | +- Be aware of the false positive/false negative rates |
| 12 | +- Reduce cognitive load on data evaluators |
| 13 | + |
| 14 | +Types of outliers/changes FlaSH intends to catch are: |
| 15 | +- Out-of-range points |
| 16 | +- Large spikes |
| 17 | +- Points that are interesting for a particular weekday |
| 18 | +- Points that are interesting with respect to a particular stream's history |
| 19 | +- Points that are interesting with respect to all other streams |
| 20 | +- Change in data reporting schedule |
| 21 | +- Changes in health condition [ex: new variant] |
| 22 | + |
| 23 | +## Running FlaSH-eval |
| 24 | + |
| 25 | +First, run the indicator so that there are files for FlaSH to check. |
| 26 | + |
| 27 | +You can excecute the Python module contained in this |
| 28 | +directory from the main directory of the indicator of interest. |
| 29 | + |
| 30 | +The safest way to do this is to create a virtual environment, |
| 31 | +and install the common DELPHI tools, including flash, and the |
| 32 | +flash module and its dependencies to the virtual environment. |
| 33 | + |
| 34 | +To do this, navigate to the main directory of the indicator of interest and run the following code: |
| 35 | + |
| 36 | +``` |
| 37 | +python -m venv env |
| 38 | +source env/bin/activate |
| 39 | +pip install ../_delphi_utils_python/. |
| 40 | +pip install . |
| 41 | +``` |
| 42 | + |
| 43 | +To execute the module run the indicator to generate data files and then run |
| 44 | +the flash system , as follows: |
| 45 | + |
| 46 | +``` |
| 47 | +env/bin/python -m delphi_INDICATORNAME |
| 48 | +env/bin/python -m delphi_utils.flash_eval |
| 49 | +
|
| 50 | +``` |
| 51 | + |
| 52 | +Once you are finished with the code, you can deactivate the virtual environment |
| 53 | +and (optionally) remove the environment itself. |
| 54 | + |
| 55 | +``` |
| 56 | +deactivate |
| 57 | +rm -r env |
| 58 | +``` |
| 59 | + |
| 60 | +### Customization |
| 61 | + |
| 62 | +All of the user-changable parameters are stored in the `flash` field of the indicator's `params.json` file. If `params.json` does not already include a `flash` field, please copy that provided in this module's `params.json.template`. |
| 63 | + |
| 64 | +Please update the follow settings: |
| 65 | +- signals: a list of which signals for that indicator go through FlaSH. |
| 66 | + |
| 67 | +## Testing the code |
| 68 | + |
| 69 | +To test the code, please create a new virtual environment in the main module directory using the following procedure, similar to above: |
| 70 | + |
| 71 | +``` |
| 72 | +make install |
| 73 | +``` |
| 74 | + |
| 75 | +To do a static test of the code style, it is recommended to run **pylint** on |
| 76 | +the module. To do this, run the following from the main module directory: |
| 77 | + |
| 78 | +``` |
| 79 | +make lint |
| 80 | +``` |
| 81 | + |
| 82 | +The most aggressive checks are turned off; only relatively important issues |
| 83 | +should be raised and they should be manually checked (or better, fixed). |
| 84 | + |
| 85 | +Unit tests are also included in the module. To execute these, run the following command from this directory: |
| 86 | + |
| 87 | +``` |
| 88 | +make test |
| 89 | +``` |
| 90 | + |
| 91 | +or |
| 92 | + |
| 93 | +``` |
| 94 | +(cd tests && ../env/bin/pytest test_file.py --cov=delphi_utils --cov-report=term-missing) |
| 95 | +``` |
| 96 | + |
| 97 | +The output will show the number of unit tests that passed and failed, along with the percentage of code covered by the tests. None of the tests should fail and the code lines that are not covered by unit tests should be small and should not include critical sub-routines. |
| 98 | + |
| 99 | + |
| 100 | +## Adding checks |
| 101 | + |
| 102 | +To add a new validation check. Each check should append a descriptive error message to the `raised` attribute if triggered. All checks should allow the user to override exception raising for a specific file using the `suppressed_errors` setting in `params.json`. |
0 commit comments