├── LICENSE ├── samples └── Seq2Seq.csv ├── .gitignore ├── README.md └── TaPR.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 saurf4ng 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /samples/Seq2Seq.csv: -------------------------------------------------------------------------------- 1 | 1754,2800,1 2 | 3080,3690,2 3 | 5299,5400,3 4 | 6063,6220,3 5 | 6838,6948,4 6 | 7314,7680,4 7 | 7700,8233,5 8 | 8345,8446,6 9 | 11472,12510,5 10 | 12602,12845,7 11 | 15442,16200,8 12 | 16337,16654,6 13 | 92560,92670,9 14 | 93452,93826,10 15 | 93988,94186,7 16 | 102756,102994,11 17 | 103092,103900,12 18 | 103444,103675,8 19 | 104106,104337,13 20 | 116206,116651,14 21 | 116766,117013,9 22 | 117020,117794,15 23 | 118016,118023,16 24 | 118027,118030,10 25 | 118032,118032,17 26 | 119921,120134,18 27 | 120596,120818,11 28 | 127438,127596,19 29 | 128648,128863,20 30 | 129143,129247,12 31 | 132918,133560,21 32 | 133628,133901,22 33 | 133938,133978,13 34 | 134383,134437,23 35 | 141159,141290,24 36 | 143012,143756,14 37 | 143881,144139,25 38 | 186701,186936,26 39 | 187572,187795,15 40 | 198357,199601,27 41 | 199978,200225,28 42 | 202801,202867,16 43 | 227963,228145,29 44 | 228638,228800,30 45 | 230385,230442,17 46 | 231861,232090,31 47 | 264041,264296,32 48 | 280030,281371,18 49 | 302739,302963,33 50 | 303301,303428,34 51 | 347829,348241,19 52 | 348618,348798,35 53 | 349017,349250,36 54 | 349725,349937,20 55 | 361822,361993,37 56 | 363662,363763,38 57 | 371605,371813,21 58 | 371906,372113,39 59 | 372455,372579,40 60 | 389638,390273,22 61 | 390536,390793,41 62 | 436575,437159,42 63 | 437305,437771,23 64 | 438113,438660,43 65 | 438267,438583,44 66 | 438665,438989,24 67 | 439210,439455,45 68 | 444307,445219,46 69 | 445454,445684,25 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A new version is released! 2 | 3 | I found that there is a limitation of TaPR. 4 | So, I propose a new version, "enhanced Time-series aware Precision and Recall (eTaPR)." 5 | 6 | Please check the below repository. 7 | https://github.com/saurf4ng/eTaPR 8 | 9 | 10 | 11 | 12 | # Time-series Aware Precision and Recall 13 | 14 | This script is developed on Python3.6. 15 | 16 | 17 | ## Input files (encoded by UTF-8) 18 | 19 | This script supports two kinds of file format. (Assume that normal and anomaly labels are '1' and '-1', respectively.) 20 | 21 | 1. Label series: each line consists of [(label)('\n')] as belows: 22 | 23 | ``` 24 | 1 25 | -1 26 | -1 27 | 1 28 | 1 29 | ``` 30 | 31 | 2. Range: each line consists of [(first_index),(last_index),(attack_name)('\n')] as belows: 32 | For example, ./sample/Seq2Seq.csv follows this format. 33 | 34 | ``` 35 | 1754,2800,1 36 | 3080,3690,2 37 | 5299,5400,3 38 | ``` 39 | 40 | 41 | ## Running 42 | 43 | python ./TaPR.py -i -c {-a} {-t} {-d} {-l}