diff options
author | Vratko Polak <vrpolak@cisco.com> | 2018-06-08 18:07:35 +0200 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2018-06-11 08:30:21 +0000 |
commit | beeb2acb9ac153eaa54983bea46a76d596168965 (patch) | |
tree | 0465617b135a2e64693265969c48ff466db3d287 /resources/tools/presentation/new/jumpavg/BitCountingClassifier.py | |
parent | 3dcef45002a1b82c4503ec590d680950930fa193 (diff) |
CSIT-1110: Integrate anomaly detection into PAL
+ Keep the original detection,
+ add the new one as subdirectory
(both in source and in rendered tree).
- The new detection is not rebased over "Add dpdk mrr tests to trending".
New detection features:
+ Do not remove (nor detect) outliers.
+ Trend line shows the constant average within a group.
+ Anomaly circles are placed at the changed average.
+ Small bias against too similar averages.
+ Should be ready for moving the detection library out to pip.
Change-Id: I7ab1a92b79eeeed53ba65a071b1305e927816a89
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/tools/presentation/new/jumpavg/BitCountingClassifier.py')
-rw-r--r-- | resources/tools/presentation/new/jumpavg/BitCountingClassifier.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/resources/tools/presentation/new/jumpavg/BitCountingClassifier.py b/resources/tools/presentation/new/jumpavg/BitCountingClassifier.py new file mode 100644 index 0000000000..69b1d65bb2 --- /dev/null +++ b/resources/tools/presentation/new/jumpavg/BitCountingClassifier.py @@ -0,0 +1,63 @@ +# Copyright (c) 2018 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from BitCountingGroup import BitCountingGroup +from BitCountingGroupList import BitCountingGroupList +from BitCountingMetadataFactory import BitCountingMetadataFactory +from ClassifiedMetadataFactory import ClassifiedMetadataFactory + + +class BitCountingClassifier(object): + + @staticmethod + def classify(values): + """Return the values in groups of optimal bit count. + + TODO: Could we return BitCountingGroupList and let caller process it? + + :param values: Sequence of runs to classify. + :type values: Iterable of float or of AvgStdevMetadata + :returns: Classified group list. + :rtype: list of BitCountingGroup + """ + max_value = BitCountingMetadataFactory.find_max_value(values) + factory = BitCountingMetadataFactory(max_value) + opened_at = [] + closed_before = [BitCountingGroupList()] + for index, value in enumerate(values): + singleton = BitCountingGroup(factory, [value]) + newly_opened = closed_before[index].with_group_appended(singleton) + opened_at.append(newly_opened) + record_group_list = newly_opened + for previous in range(index): + previous_opened_list = opened_at[previous] + still_opened = ( + previous_opened_list.with_value_added_to_last_group(value)) + opened_at[previous] = still_opened + if still_opened.bits < record_group_list.bits: + record_group_list = still_opened + closed_before.append(record_group_list) + partition = closed_before[-1] + previous_average = partition[0].metadata.avg + for group in partition: + if group.metadata.avg == previous_average: + group.metadata = ClassifiedMetadataFactory.with_classification( + group.metadata, "normal") + elif group.metadata.avg < previous_average: + group.metadata = ClassifiedMetadataFactory.with_classification( + group.metadata, "regression") + elif group.metadata.avg > previous_average: + group.metadata = ClassifiedMetadataFactory.with_classification( + group.metadata, "progression") + previous_average = group.metadata.avg + return partition.group_list |