From 18e152bec4514a5aa7cb0cbb68f0dc05fe0f288b Mon Sep 17 00:00:00 2001 From: Duan Juanyong Date: Fri, 31 May 2024 15:14:00 +0800 Subject: [PATCH] Main (#47) * Merge Anomaly Detector code into main (#43) * update python version & add tests for different python versions * update python version & add tests for different python versions (#14) * update setup.py (#13) * add uvad and test * step1 * setp2 * update Readme.md * add dockerfile ,move get_margins * fix predict * delete pyd * build success * add build.py but no .pyd file generated * update setup.py * fix some error * add model folder --------- Co-authored-by: Duan Juanyong * update gitignore * remove r dependency (#16) * remove r dependency * replace rpy2 with rstl * update * add build and release workflow (#12) * Bump gitpython from 3.1.40 to 3.1.41 in /anomaly-detector (#4) Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.40 to 3.1.41. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.40...3.1.41) --- updated-dependencies: - dependency-name: gitpython dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jinja2 from 3.1.2 to 3.1.3 in /anomaly-detector (#6) Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3) --- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add build workflow * add build workflow * add build workflow * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * merge --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * test on different python version (#17) * Bump gitpython from 3.1.40 to 3.1.41 in /anomaly-detector (#4) Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.40 to 3.1.41. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.40...3.1.41) --- updated-dependencies: - dependency-name: gitpython dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jinja2 from 3.1.2 to 3.1.3 in /anomaly-detector (#6) Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3) --- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add build workflow * add build workflow * add build workflow * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * merge * add more test cases * delete some uvad test cases * delete some uvad test cases * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add caching packages dependencies * add cache dependencies to boost test * add cache dependencies to boost test * Update ci.yml --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * update param check * test mlflow on UnivariateAnomalyDetector, add new class (#18) * add e2e_test for UnivariateAnomalyDetector * add EntireAnomalyDetector, LatestAnomalyDetector * rename * update model output & usage * update test, remove saving results * update model output to avoid duplicated keys * check insufficient predict data * test output (#20) * Bump gitpython from 3.1.40 to 3.1.41 in /anomaly-detector (#4) Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.40 to 3.1.41. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.40...3.1.41) --- updated-dependencies: - dependency-name: gitpython dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jinja2 from 3.1.2 to 3.1.3 in /anomaly-detector (#6) Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3) --- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add build workflow * add build workflow * add build workflow * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * merge * add more test cases * delete some uvad test cases * delete some uvad test cases * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add caching packages dependencies * add cache dependencies to boost test * add cache dependencies to boost test * Update ci.yml * test output * test output * test output * add license to all .py file --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * update numpy version to 1.26.x (#21) * add e2e_test for UnivariateAnomalyDetector * add EntireAnomalyDetector, LatestAnomalyDetector * rename * update numpy version to 1.26.x * update Dockerfile & pandas version * Update pyproject.toml numpy>=1.23.5 * update ci.yml * fix expectedValue error * Update pipeline for pypi publish (#22) * update gitignore * update build pipeline to push to pypi * Merge (#23) * update gitignore * update build pipeline to push to pypi * install deps * update pipeline (#24) * update pipeline (#25) * update pipeline (#26) * update build option * add wheel * update pipeline * add long description * add long text description type * change package name * uploade src only * update maintainer * update build * Bump mlflow from 2.9.2 to 2.10.0 in /anomaly-detector Bumps [mlflow](https://github.com/mlflow/mlflow) from 2.9.2 to 2.10.0. - [Release notes](https://github.com/mlflow/mlflow/releases) - [Changelog](https://github.com/mlflow/mlflow/blob/master/CHANGELOG.md) - [Commits](https://github.com/mlflow/mlflow/compare/v2.9.2...v2.10.0) --- updated-dependencies: - dependency-name: mlflow dependency-type: direct:production ... Signed-off-by: dependabot[bot] * change package name * update version * Update README.md * update pipeline * update workflow file * add sample notebook * update workflow and ignore file * add numpy for build * change trigger condition * release version v0.2.2 (#41) * fix error in publish pipeline --------- Signed-off-by: dependabot[bot] Co-authored-by: shuawei <154395194+v-shuawei@users.noreply.github.com> Co-authored-by: luxiong-ms1 <151121855+luxiong-ms1@users.noreply.github.com> Co-authored-by: Zeke Xia <43031121+CodeFree-xzk@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jr-MS <81400625+jr-MS@users.noreply.github.com> Co-authored-by: Zeke Xia * add release key * remove unexpected value * change release to gh release * update pipeline * debug * debug * debug path * Merge Anomaly Detector code into main (#43) * update python version & add tests for different python versions * update python version & add tests for different python versions (#14) * update setup.py (#13) * add uvad and test * step1 * setp2 * update Readme.md * add dockerfile ,move get_margins * fix predict * delete pyd * build success * add build.py but no .pyd file generated * update setup.py * fix some error * add model folder --------- Co-authored-by: Duan Juanyong * update gitignore * remove r dependency (#16) * remove r dependency * replace rpy2 with rstl * update * add build and release workflow (#12) * Bump gitpython from 3.1.40 to 3.1.41 in /anomaly-detector (#4) Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.40 to 3.1.41. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.40...3.1.41) --- updated-dependencies: - dependency-name: gitpython dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jinja2 from 3.1.2 to 3.1.3 in /anomaly-detector (#6) Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3) --- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add build workflow * add build workflow * add build workflow * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * merge --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * test on different python version (#17) * Bump gitpython from 3.1.40 to 3.1.41 in /anomaly-detector (#4) Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.40 to 3.1.41. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.40...3.1.41) --- updated-dependencies: - dependency-name: gitpython dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jinja2 from 3.1.2 to 3.1.3 in /anomaly-detector (#6) Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3) --- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add build workflow * add build workflow * add build workflow * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * merge * add more test cases * delete some uvad test cases * delete some uvad test cases * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add caching packages dependencies * add cache dependencies to boost test * add cache dependencies to boost test * Update ci.yml --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * update param check * test mlflow on UnivariateAnomalyDetector, add new class (#18) * add e2e_test for UnivariateAnomalyDetector * add EntireAnomalyDetector, LatestAnomalyDetector * rename * update model output & usage * update test, remove saving results * update model output to avoid duplicated keys * check insufficient predict data * test output (#20) * Bump gitpython from 3.1.40 to 3.1.41 in /anomaly-detector (#4) Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.40 to 3.1.41. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.40...3.1.41) --- updated-dependencies: - dependency-name: gitpython dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jinja2 from 3.1.2 to 3.1.3 in /anomaly-detector (#6) Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3) --- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add build workflow * add build workflow * add build workflow * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * test poetry install * merge * add more test cases * delete some uvad test cases * delete some uvad test cases * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add different python version * add caching packages dependencies * add cache dependencies to boost test * add cache dependencies to boost test * Update ci.yml * test output * test output * test output * add license to all .py file --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * update numpy version to 1.26.x (#21) * add e2e_test for UnivariateAnomalyDetector * add EntireAnomalyDetector, LatestAnomalyDetector * rename * update numpy version to 1.26.x * update Dockerfile & pandas version * Update pyproject.toml numpy>=1.23.5 * update ci.yml * fix expectedValue error * Update pipeline for pypi publish (#22) * update gitignore * update build pipeline to push to pypi * Merge (#23) * update gitignore * update build pipeline to push to pypi * install deps * update pipeline (#24) * update pipeline (#25) * update pipeline (#26) * update build option * add wheel * update pipeline * add long description * add long text description type * change package name * uploade src only * update maintainer * update build * Bump mlflow from 2.9.2 to 2.10.0 in /anomaly-detector Bumps [mlflow](https://github.com/mlflow/mlflow) from 2.9.2 to 2.10.0. - [Release notes](https://github.com/mlflow/mlflow/releases) - [Changelog](https://github.com/mlflow/mlflow/blob/master/CHANGELOG.md) - [Commits](https://github.com/mlflow/mlflow/compare/v2.9.2...v2.10.0) --- updated-dependencies: - dependency-name: mlflow dependency-type: direct:production ... Signed-off-by: dependabot[bot] * change package name * update version * Update README.md * update pipeline * update workflow file * add sample notebook * update workflow and ignore file * add numpy for build * change trigger condition * release version v0.2.2 (#41) * fix error in publish pipeline --------- Signed-off-by: dependabot[bot] Co-authored-by: shuawei <154395194+v-shuawei@users.noreply.github.com> Co-authored-by: luxiong-ms1 <151121855+luxiong-ms1@users.noreply.github.com> Co-authored-by: Zeke Xia <43031121+CodeFree-xzk@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jr-MS <81400625+jr-MS@users.noreply.github.com> Co-authored-by: Zeke Xia --------- Signed-off-by: dependabot[bot] Co-authored-by: shuawei <154395194+v-shuawei@users.noreply.github.com> Co-authored-by: luxiong-ms1 <151121855+luxiong-ms1@users.noreply.github.com> Co-authored-by: Zeke Xia <43031121+CodeFree-xzk@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jr-MS <81400625+jr-MS@users.noreply.github.com> Co-authored-by: Zeke Xia --- src/anomaly_detector/univariate/model/__init__.py | 3 +-- src/anomaly_detector/univariate/util/__init__.py | 2 +- src/anomaly_detector/univariate/util/helpers.py | 12 ++++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/anomaly_detector/univariate/model/__init__.py b/src/anomaly_detector/univariate/model/__init__.py index d02a9af..9dd81a3 100644 --- a/src/anomaly_detector/univariate/model/__init__.py +++ b/src/anomaly_detector/univariate/model/__init__.py @@ -1,4 +1,3 @@ # --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# --------------------------------------------------------- - +# --------------------------------------------------------- \ No newline at end of file diff --git a/src/anomaly_detector/univariate/util/__init__.py b/src/anomaly_detector/univariate/util/__init__.py index f050678..e4953a9 100644 --- a/src/anomaly_detector/univariate/util/__init__.py +++ b/src/anomaly_detector/univariate/util/__init__.py @@ -6,4 +6,4 @@ from .helpers import * from .stl_helpers import * from .r_stl import stl, stl_adjust_trend -from .refine import * +from .refine import * \ No newline at end of file diff --git a/src/anomaly_detector/univariate/util/helpers.py b/src/anomaly_detector/univariate/util/helpers.py index 84c6962..c912e7a 100644 --- a/src/anomaly_detector/univariate/util/helpers.py +++ b/src/anomaly_detector/univariate/util/helpers.py @@ -34,7 +34,7 @@ def leastsq(x, y): return a, b -def average_filter(values, n=3, fill_to_n = False): +def average_filter(values, n=3, fill_to_n=False): """ Calculate the sliding window average for the give time series. Mathematically, res[i] = sum_{j=i-t+1}^{i} values[j] / t, where t = min(n, i+1) @@ -45,7 +45,7 @@ def average_filter(values, n=3, fill_to_n = False): :return res: list. a list of value after the average_filter process. """ - fill_n=n + fill_n = n if n >= len(values): n = len(values) @@ -55,7 +55,7 @@ def average_filter(values, n=3, fill_to_n = False): for i in range(1, n): if fill_to_n: - res[i] = (res[i] + ((res[i]-values[i]) / i) * (fill_n-i-1)) / fill_n + res[i] = (res[i] + ((res[i] - values[i]) / i) * (fill_n - i - 1)) / fill_n else: res[i] /= (i + 1) @@ -106,7 +106,7 @@ def guess_trended_period(data): broad = fit_trend(data, kind="median", period=max_period) if np.any(~np.isfinite(broad)): raise Exception(ValueOverflow) - + peaks = periodogram_peaks(data - broad) if peaks is None: return max_period @@ -259,14 +259,14 @@ def normalize(values, min_max=False): def smooth_spikes(data): std = data.std() + 1e-8 mean = data.mean() - anomaly_index = [] if std == 0 else np.where(np.abs(data-mean) / std >= 3)[0] + anomaly_index = [] if std == 0 else np.where(np.abs(data - mean) / std >= 3)[0] series = pd.Series(data, copy=True) series[anomaly_index] = np.nan return series.interpolate(method='linear', limit_direction='both').values def get_delta(delta, values): - d_values = [values[i] - values[i-1] for i in range(1, len(values))] + d_values = [values[i] - values[i - 1] for i in range(1, len(values))] d_values = [d_values[delta]] * (delta + 1) + d_values[delta:] return d_values