tsadmetrics 1.0.0__py3-none-any.whl → 1.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
docs/conf.py ADDED
@@ -0,0 +1,67 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+
4
+ import os
5
+ import sys
6
+ sys.path.insert(0, os.path.abspath('../'))
7
+
8
+
9
+ project = 'TSADmetrics'
10
+ copyright = '2025, Pedro Rafael Velasco Priego'
11
+ author = 'Pedro Rafael Velasco Priego'
12
+ release = 'MIT'
13
+
14
+ # -- General configuration ---------------------------------------------------
15
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
16
+
17
+
18
+ extensions = ['sphinx.ext.duration', 'sphinx.ext.doctest', 'sphinx.ext.autodoc','sphinx.ext.mathjax']
19
+
20
+
21
+
22
+ templates_path = ['_templates']
23
+ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
24
+
25
+ html_theme = 'furo'
26
+ html_static_path = ['_static']
27
+ html_theme_options = {
28
+ #"sidebar_hide_name": True,
29
+ "light_css_variables": {
30
+ "color-brand-primary": "#2e5c7d",
31
+ "color-brand-content": "#2e5c7d",
32
+ "codebgcolor": "red",
33
+ "codetextcolor": "red",
34
+ },
35
+ "dark_css_variables": {
36
+ "color-brand-primary": "#6998b4",
37
+ "color-brand-content": "#6998b4",
38
+ "codebgcolor": "green",
39
+ "codetextcolor": "green",
40
+ },
41
+ "navigation_with_keys": True
42
+
43
+ }
44
+ html_baseurl = ''
45
+
46
+ html_css_files = [
47
+ 'css/custom.css',
48
+ ]
49
+
50
+ epub_show_urls = 'footnote'
51
+
52
+ # -- Options for HTML output -------------------------------------------------
53
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
54
+
55
+
56
+
57
+
58
+ ### -- LaTeX options -------------------------------------------------
59
+
60
+ # comando para compilar: make latexpdf LATEXMKOPTS="-xelatex"
61
+
62
+ latex_elements = {
63
+ 'maxlistdepth': '10', # Aumenta el límite de anidamiento
64
+ 'papersize': 'a4paper',
65
+ 'pointsize': '10pt',
66
+
67
+ }
@@ -1,25 +1,27 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tsadmetrics
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: Librería para evaluación de detección de anomalías en series temporales
5
5
  Home-page: https://github.com/pathsko/TSADmetrics
6
6
  Author: Pedro Rafael Velasco Priego
7
7
  Author-email: Pedro Rafael Velasco Priego <i12veprp@uco.es>
8
8
  Requires-Python: >=3.8
9
9
  Description-Content-Type: text/markdown
10
- Requires-Dist: joblib==1.4.2
11
10
  Requires-Dist: numpy==1.24.4
12
11
  Requires-Dist: pandas==2.0.3
13
12
  Requires-Dist: PATE==0.1.1
14
- Requires-Dist: patsy==0.5.6
15
- Requires-Dist: python-dateutil==2.9.0.post0
16
- Requires-Dist: pytz==2024.1
17
- Requires-Dist: scikit-learn==1.3.2
18
- Requires-Dist: scipy==1.10.1
19
- Requires-Dist: six==1.16.0
20
- Requires-Dist: statsmodels==0.14.1
21
- Requires-Dist: threadpoolctl==3.5.0
22
- Requires-Dist: tzdata==2024.1
13
+ Requires-Dist: PyYAML==6.0.2
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest==8.3.5; extra == "dev"
16
+ Requires-Dist: iniconfig==2.1.0; extra == "dev"
17
+ Requires-Dist: pluggy==1.5.0; extra == "dev"
18
+ Requires-Dist: tomli==2.2.1; extra == "dev"
19
+ Requires-Dist: exceptiongroup==1.3.0; extra == "dev"
20
+ Requires-Dist: ipython>=7.0; extra == "dev"
21
+ Requires-Dist: sphinx; extra == "dev"
22
+ Requires-Dist: sphinx-rtd-theme; extra == "dev"
23
+ Requires-Dist: numpydoc; extra == "dev"
24
+ Requires-Dist: myst-parser; extra == "dev"
23
25
 
24
26
  # TSADmetrics - Time Series Anomaly Detection Metrics
25
27
 
@@ -1,6 +1,7 @@
1
- docs/api_doc/conf.py,sha256=wuQ4yqLoAE_C5t2crlg1ILpc9Zv5BxTrCFuzKvCtmK0,1679
2
- docs/full_doc/conf.py,sha256=E6PG3lG1_G1MrLlRaKb1zZ7LiCiGoYsKnZXETEouKpE,1665
3
- docs/manual_doc/conf.py,sha256=tnfQLdyr9BhOW-r1uSnJHNnAMsPx9e-Vif5ISXpX4h8,1677
1
+ docs/conf.py,sha256=E6PG3lG1_G1MrLlRaKb1zZ7LiCiGoYsKnZXETEouKpE,1665
2
+ docs/add_docs/api_doc/conf.py,sha256=wuQ4yqLoAE_C5t2crlg1ILpc9Zv5BxTrCFuzKvCtmK0,1679
3
+ docs/add_docs/full_doc/conf.py,sha256=E6PG3lG1_G1MrLlRaKb1zZ7LiCiGoYsKnZXETEouKpE,1665
4
+ docs/add_docs/manual_doc/conf.py,sha256=tnfQLdyr9BhOW-r1uSnJHNnAMsPx9e-Vif5ISXpX4h8,1677
4
5
  examples/example_direct_data.py,sha256=FQuOplQURSYArXn4BfMiWY5g3g1sjFllqG2duoXOOvU,929
5
6
  examples/example_direct_single_data.py,sha256=RTsy7ZfInwZ3W7g2iDeP-HqzIzCPtIDcSnt_c5M9he4,719
6
7
  examples/example_file_reference.py,sha256=BInUK4VtqZfmW9C_LW8pJhtcj3d8LMQ8VFdjd3dMHyo,582
@@ -32,15 +33,6 @@ examples/specific_examples/TotalDetectedInRange_example.py,sha256=Z-b_gnaUX8xzoj
32
33
  examples/specific_examples/VusPr_example.py,sha256=74tWoZ-eljpBgrzxRaaGPIY201vr4R-0QjA4Fh4AihU,580
33
34
  examples/specific_examples/VusRoc_example.py,sha256=_jkRWH426i4jc9eRC4_58MKJ53qVkGiNa1gqTOKTG3g,585
34
35
  examples/specific_examples/WeightedDetectionDifference_example.py,sha256=L6a6WHJosocfigmf9RY-RnqWOY0aJDLBzVtT0SKjn8k,647
35
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- tests/test_dpm.py,sha256=QHQcc0LlzRJt7eCjVlwLhdrBnO3XI23NaYdY8X6U-vg,8208
37
- tests/test_ptdm.py,sha256=odB6xWDSKPsCBitYbeA2nwEV6LdCawA244Ym-xXIujY,13866
38
- tests/test_registry.py,sha256=e4EGT5PUexU0rHk5XYd5gdPC-bfujQz8UAPTcfxiLjE,2120
39
- tests/test_runner.py,sha256=zIIUz9f8nVD9hspuXe1SYd4_nAeXZyGenU-_ImQ-clQ,6121
40
- tests/test_spm.py,sha256=g6ugbJF6ifI8FmTgP0N5l-j38yKKT1V_E45oOuTbE0E,6694
41
- tests/test_tmem.py,sha256=dSARU9lntPFiUJVBTizaoaSZiklreaGTPZr9-J3Goac,7344
42
- tests/test_tpdm.py,sha256=Z-Yga8A-C3TkHGk24uJN04COxhFaVuGw6QFeVcxYCTU,15083
43
- tests/test_tstm.py,sha256=2X3J1_ttIUkx1zSYJClcZkfGxjfPxLnwHjnKeRLuGl8,12555
44
36
  tsadmetrics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
37
  tsadmetrics/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
38
  tsadmetrics/base/Metric.py,sha256=xbntR43SGvHwByQFtrleE_O16x9GrHuburxxYzpIofc,6998
@@ -93,7 +85,7 @@ tsadmetrics/utils/functions_counting_metrics.py,sha256=opEz2c4xOlvnLuWpGTZBkUA4k
93
85
  tsadmetrics/utils/functions_latency_sparsity_aware.py,sha256=2-GbRj2-jI0VPu7glrUryxbvtd8cizpmvhQ7uzGFdvU,12092
94
86
  tsadmetrics/utils/functions_nabscore.py,sha256=1iT57dckcxkJFm7tV_X5-XKJ6ueBfspQpCt1JdHYoac,12495
95
87
  tsadmetrics/utils/functions_vus.py,sha256=XL5tV9hxBW8aGkobT84cp2FdHNuNZ3PUgaplwHsDjNk,7868
96
- tsadmetrics-1.0.0.dist-info/METADATA,sha256=t-37fsC1UexgHScUtOQvT_p6pfir-u4NqyHZAUgKhQo,2643
97
- tsadmetrics-1.0.0.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
98
- tsadmetrics-1.0.0.dist-info/top_level.txt,sha256=IptcbM5CG9bfWYHoktby_pPifTLfzzFiehJ2g-iZMC4,32
99
- tsadmetrics-1.0.0.dist-info/RECORD,,
88
+ tsadmetrics-1.0.2.dist-info/METADATA,sha256=duKplRSvFNQPAsYqdka4ob1XzE_UqJ9QJrx6diDAGsk,2819
89
+ tsadmetrics-1.0.2.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
90
+ tsadmetrics-1.0.2.dist-info/top_level.txt,sha256=SQyE4h3YKaCI8-Cqe-irh5ig4trxq2ZIg8bV0xZ1_UQ,26
91
+ tsadmetrics-1.0.2.dist-info/RECORD,,
@@ -1,4 +1,3 @@
1
1
  docs
2
2
  examples
3
- tests
4
3
  tsadmetrics
tests/__init__.py DELETED
File without changes
tests/test_dpm.py DELETED
@@ -1,212 +0,0 @@
1
- import unittest
2
-
3
- import numpy as np
4
- import random
5
-
6
- import unittest
7
- import numpy as np
8
- from tsadmetrics.metrics.tem.dpm import *
9
-
10
- class TestDelayThresholdedPointadjustedFScore(unittest.TestCase):
11
-
12
- def setUp(self):
13
-
14
- self.y_true = np.array([0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1])
15
- self.y_pred1 = np.array([0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
16
- self.y_pred2 = np.array([0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0])
17
- self.y_pred3 = self.y_true
18
- self.y_pred4 = np.zeros(len(self.y_true))
19
-
20
-
21
-
22
- def test(self):
23
- metric = DelayThresholdedPointadjustedFScore(k=2, beta=1.0)
24
- f_score = round(metric.compute(self.y_true, self.y_pred1),2)
25
- expected_f_score = 0.67
26
- self.assertAlmostEqual(f_score, expected_f_score, places=4)
27
-
28
- f_score = round(metric.compute(self.y_true, self.y_pred2),2)
29
- expected_f_score = 1
30
- self.assertAlmostEqual(f_score, expected_f_score, places=4)
31
-
32
- score = round(metric.compute(self.y_true, self.y_pred3),2)
33
- expected_metric = 1.0
34
- self.assertAlmostEqual(score, expected_metric, places=4)
35
-
36
- score = round(metric.compute(self.y_true, self.y_pred4),2)
37
- expected_metric = 0
38
- self.assertAlmostEqual(score, expected_metric, places=4)
39
-
40
- def test_consistency(self):
41
- try:
42
- y_true = np.random.choice([0, 1], size=(100,))
43
- y_pred = np.zeros(100)
44
- metric = DelayThresholdedPointadjustedFScore(k=2, beta=1.0)
45
- metric.compute(y_true, y_pred)
46
- for _ in range(1000):
47
- y_true = np.random.choice([0, 1], size=(100,))
48
- y_pred = np.random.choice([0, 1], size=(100,))
49
- f_score = metric.compute(y_true, y_pred)
50
- except Exception as e:
51
- self.fail(f"DelayThresholdedPointadjustedFScore raised an exception {e}")
52
-
53
-
54
- class TestLatencySparsityawareFScore(unittest.TestCase):
55
-
56
- def setUp(self):
57
-
58
- self.y_true = np.array([0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1])
59
- self.y_pred1 = np.array([0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
60
- self.y_pred2 = np.array([0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0])
61
- self.y_pred3 = self.y_true
62
- self.y_pred4 = np.zeros(len(self.y_true))
63
-
64
- def test(self):
65
- metric = LatencySparsityawareFScore(ni=2, beta=1.0)
66
- f_score = round(metric.compute(self.y_true, self.y_pred1),2)
67
- expected_f_score = 0.71
68
- self.assertAlmostEqual(f_score, expected_f_score, places=4)
69
-
70
- f_score = round(metric.compute(self.y_true, self.y_pred2),2)
71
- expected_f_score = 1
72
- self.assertAlmostEqual(f_score, expected_f_score, places=4)
73
-
74
- score = round(metric.compute(self.y_true, self.y_pred3),2)
75
- expected_metric = 1.0
76
- self.assertAlmostEqual(score, expected_metric, places=4)
77
-
78
- score = round(metric.compute(self.y_true, self.y_pred4),2)
79
- expected_metric = 0
80
- self.assertAlmostEqual(score, expected_metric, places=4)
81
-
82
- def test_consistency(self):
83
- try:
84
- y_true = np.random.choice([0, 1], size=(100,))
85
- y_pred = np.zeros(100)
86
- metric = LatencySparsityawareFScore(ni=2, beta=1.0)
87
- metric.compute(y_true, y_pred)
88
- for _ in range(1000):
89
- y_true = np.random.choice([0, 1], size=(100,))
90
- y_pred = np.random.choice([0, 1], size=(100,))
91
- f_score = metric.compute(y_true, y_pred)
92
- except Exception as e:
93
- self.fail(f"LatencySparsityawareFScore raised an exception {e}")
94
-
95
-
96
- class TestMeanTimeToDetect(unittest.TestCase):
97
-
98
- def setUp(self):
99
-
100
- self.y_true1 = np.array([0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1])
101
- self.y_pred1 = np.array([0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
102
- self.y_pred2 = np.array([0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0])
103
-
104
- self.y_true2 = np.array([0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1])
105
- self.y_pred21 = np.array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1])
106
- self.y_pred22 = np.array([0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0])
107
-
108
- self.y_pred3 = self.y_true1
109
- self.y_pred4 = np.zeros(len(self.y_true1))
110
-
111
- def test(self):
112
- metric = MeanTimeToDetect()
113
- score = round(metric.compute(self.y_true1, self.y_pred1),2)
114
- expected_score = 0.0
115
- self.assertAlmostEqual(score, expected_score, places=4)
116
-
117
- score = round(metric.compute(self.y_true1, self.y_pred2),2)
118
- expected_score = 0.0
119
- self.assertAlmostEqual(score, expected_score, places=4)
120
-
121
- score = round(metric.compute(self.y_true2, self.y_pred21),2)
122
- expected_score = 8.0
123
- self.assertAlmostEqual(score, expected_score, places=4)
124
-
125
- score = round(metric.compute(self.y_true2, self.y_pred22),2)
126
- expected_score = 0.0
127
- self.assertAlmostEqual(score, expected_score, places=4)
128
-
129
- score = round(metric.compute(self.y_true1, self.y_pred3),2)
130
- expected_metric = 0.0
131
- self.assertAlmostEqual(score, expected_metric, places=4)
132
-
133
- score = round(metric.compute(self.y_true1, self.y_pred4),2)
134
- expected_metric = 0.0
135
- self.assertAlmostEqual(score, expected_metric, places=4)
136
-
137
-
138
-
139
-
140
-
141
- def test_consistency(self):
142
- try:
143
-
144
- y_true = np.random.choice([0, 1], size=(100,))
145
- y_pred = np.zeros(100)
146
- metric = MeanTimeToDetect()
147
- metric.compute(y_true, y_pred)
148
- for _ in range(100):
149
- y_true = np.random.choice([0, 1], size=(100,))
150
- y_pred = np.random.choice([0, 1], size=(100,))
151
-
152
- score = metric.compute(y_true, y_pred)
153
- except Exception as e:
154
- self.fail(f"MeanTimeToDetect raised an exception {e}")
155
-
156
-
157
- class TestNabScore(unittest.TestCase):
158
-
159
- def setUp(self):
160
-
161
- self.y_true1 = np.array([0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1])
162
- self.y_pred1 = np.array([0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
163
- self.y_pred2 = np.array([0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0])
164
-
165
- self.y_true2 = np.array([0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1])
166
- self.y_pred21 = np.array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1])
167
- self.y_pred22 = np.array([0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0])
168
-
169
- self.y_pred3 = self.y_true1
170
- self.y_pred4 = np.zeros(len(self.y_true1))
171
-
172
-
173
-
174
- def test(self):
175
- metric = NabScore()
176
- f_score = round(metric.compute(self.y_true1, self.y_pred1),2)
177
- expected_f_score = 50
178
- self.assertAlmostEqual(f_score, expected_f_score, places=4)
179
-
180
- f_score = round(metric.compute(self.y_true1, self.y_pred2),2)
181
- expected_f_score = 100
182
- self.assertAlmostEqual(f_score, expected_f_score, places=4)
183
-
184
- f_score = round(metric.compute(self.y_true2, self.y_pred21),2)
185
- expected_f_score = 33.33
186
- self.assertAlmostEqual(f_score, expected_f_score, places=4)
187
-
188
- f_score = round(metric.compute(self.y_true2, self.y_pred22),2)
189
- expected_f_score = 66.67
190
- self.assertAlmostEqual(f_score, expected_f_score, places=4)
191
-
192
- score = round(metric.compute(self.y_true1, self.y_pred3),2)
193
- expected_metric = 100
194
- self.assertAlmostEqual(score, expected_metric, places=4)
195
-
196
- score = round(metric.compute(self.y_true1, self.y_pred4),2)
197
- expected_metric = 0
198
- self.assertAlmostEqual(score, expected_metric, places=4)
199
-
200
- def test_consistency(self):
201
- try:
202
- metric = NabScore()
203
- y_true = np.random.choice([0, 1], size=(100,))
204
- y_pred = np.zeros(100)
205
- metric.compute(y_true, y_pred)
206
- for _ in range(100):
207
- y_true = np.random.choice([0, 1], size=(100,))
208
- y_pred = np.random.choice([0, 1], size=(100,))
209
-
210
- score = metric.compute(y_true, y_pred)
211
- except Exception as e:
212
- self.fail(f"NabScore raised an exception {e}")