The known anomalies in a time series could be of length one. In that case, the current segment based scoring function will not consider the existence of an overlap.
def _partition(expected, observed, start=None, end=None):
edges = set()
if start is not None:
edges.add(start)
if end is not None:
edges.add(end)
for edge in expected + observed:
edges.update(edge)
partitions = list()
edges = sorted(edges)
last = edges[0]
for edge in edges[1:]:
partitions.append((last, edge))
last = edge
expected_parts = list()
observed_parts = list()
weights = list()
for part in partitions:
weights.append(part[1] - part[0] + 1)
expected_parts.append(_any_overlap(part, expected))
observed_parts.append(_any_overlap(part, observed))
return expected_parts, observed_parts, weights
If we look at the _partition
function, we notice that edges
is a set and will only include unique edges.
But an example of a perfectly detected anomalies can be as follows:
known_anomalies =
| start | end |
|-------|-----|
| 3 | 3 |
observed anomalies =
| start | end |
|-------|-----|
| 3 | 3 |
Now edges = {3}
, and therefore, the result of this function will be an empty partition.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4