diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c73820301..02d0e1290 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,6 @@ on: jobs: tests: - runs-on: ubuntu-latest strategy: fail-fast: false @@ -22,15 +21,19 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Set up Java 17 + uses: actions/setup-java@v3 + with: + distribution: adopt + java-version: 17 + - name: Install Merlion run: | - sudo apt-get update -y - sudo apt-get install bc openjdk-11-jre-headless -y --fix-missing python -m pip install --upgrade pip setuptools wheel build python -m pip install pytest coverage python -m build - for f in dist/*.whl; do pip install $f[all]; done - pip install -e ts_datasets/ + for f in dist/*.whl; do python -m pip install $f[all]; done + python -m pip install -e ts_datasets/ - name: Test with pytest id: test @@ -86,3 +89,35 @@ jobs: BRANCH: badges FOLDER: .github/badges GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + tests_windows: + + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10"] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Set up Java 17 + uses: actions/setup-java@v3 + with: + distribution: microsoft + java-version: 17 + + - name: Install Merlion + run: | + python -m pip install --upgrade pip setuptools wheel build pytest + python -m pip install ".[all]" + python -m pip install -e ts_datasets/ + + - name: Test with pytest + id: test + run: pytest -v -s --ignore=tests/spark diff --git a/merlion/dashboard/__init__.py b/merlion/dashboard/__init__.py index 92d093b27..9cf4af824 100644 --- a/merlion/dashboard/__init__.py +++ b/merlion/dashboard/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/__main__.py b/merlion/dashboard/__main__.py index e8f571cd7..c41a58903 100644 --- a/merlion/dashboard/__main__.py +++ b/merlion/dashboard/__main__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/callbacks/__init__.py b/merlion/dashboard/callbacks/__init__.py index 599d47c29..5b913d9ad 100644 --- a/merlion/dashboard/callbacks/__init__.py +++ b/merlion/dashboard/callbacks/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/callbacks/anomaly.py b/merlion/dashboard/callbacks/anomaly.py index 0e4ec0b10..4cb63bb74 100755 --- a/merlion/dashboard/callbacks/anomaly.py +++ b/merlion/dashboard/callbacks/anomaly.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/callbacks/data.py b/merlion/dashboard/callbacks/data.py index 660178cb8..9149b39d5 100644 --- a/merlion/dashboard/callbacks/data.py +++ b/merlion/dashboard/callbacks/data.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/callbacks/forecast.py b/merlion/dashboard/callbacks/forecast.py index 9e9717aa0..139654062 100755 --- a/merlion/dashboard/callbacks/forecast.py +++ b/merlion/dashboard/callbacks/forecast.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/models/__init__.py b/merlion/dashboard/models/__init__.py index 599d47c29..5b913d9ad 100644 --- a/merlion/dashboard/models/__init__.py +++ b/merlion/dashboard/models/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/models/data.py b/merlion/dashboard/models/data.py index d58cd89ef..c5d1ce55d 100644 --- a/merlion/dashboard/models/data.py +++ b/merlion/dashboard/models/data.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/models/utils.py b/merlion/dashboard/models/utils.py index ae0d07a21..2e431b3c2 100644 --- a/merlion/dashboard/models/utils.py +++ b/merlion/dashboard/models/utils.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/pages/__init__.py b/merlion/dashboard/pages/__init__.py index 599d47c29..5b913d9ad 100644 --- a/merlion/dashboard/pages/__init__.py +++ b/merlion/dashboard/pages/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/pages/anomaly.py b/merlion/dashboard/pages/anomaly.py index db3561f8e..0f5ef38b3 100755 --- a/merlion/dashboard/pages/anomaly.py +++ b/merlion/dashboard/pages/anomaly.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/pages/data.py b/merlion/dashboard/pages/data.py index c9eb0b78a..db4c5e137 100644 --- a/merlion/dashboard/pages/data.py +++ b/merlion/dashboard/pages/data.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/pages/forecast.py b/merlion/dashboard/pages/forecast.py index 71e14f8e9..b4003855c 100755 --- a/merlion/dashboard/pages/forecast.py +++ b/merlion/dashboard/pages/forecast.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -96,7 +96,7 @@ def create_control_panel() -> html.Div: html.Br(), html.P("Algorithm Setting"), html.Div(id="forecasting-param-table", children=[create_param_table()]), - html.Progress(id="forecasting-progressbar", style={"width": "100%", 'color':'#1AB9FF'}), + html.Progress(id="forecasting-progressbar", style={"width": "100%", "color": "#1AB9FF"}), html.Br(), html.Div( children=[ diff --git a/merlion/dashboard/pages/utils.py b/merlion/dashboard/pages/utils.py index a89f604fa..f4022354f 100644 --- a/merlion/dashboard/pages/utils.py +++ b/merlion/dashboard/pages/utils.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/server.py b/merlion/dashboard/server.py index e3f45d7fd..8fff5b9b3 100644 --- a/merlion/dashboard/server.py +++ b/merlion/dashboard/server.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/settings.py b/merlion/dashboard/settings.py index 7bbfed9ce..083117ec0 100644 --- a/merlion/dashboard/settings.py +++ b/merlion/dashboard/settings.py @@ -1,8 +1,8 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause # TABLE_HEADER_COLOR = "#014486" -TABLE_DATA_COLOR = 'white' +TABLE_DATA_COLOR = "white" diff --git a/merlion/dashboard/utils/__init__.py b/merlion/dashboard/utils/__init__.py index 599d47c29..5b913d9ad 100644 --- a/merlion/dashboard/utils/__init__.py +++ b/merlion/dashboard/utils/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/utils/file_manager.py b/merlion/dashboard/utils/file_manager.py index a5056532c..d2f4dec81 100644 --- a/merlion/dashboard/utils/file_manager.py +++ b/merlion/dashboard/utils/file_manager.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/utils/layout.py b/merlion/dashboard/utils/layout.py index cce7426b3..0688902c2 100644 --- a/merlion/dashboard/utils/layout.py +++ b/merlion/dashboard/utils/layout.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -9,8 +9,8 @@ tab_style = { - "borderBottom": "1px solid #d6d6d6", - "padding": "6px", + "borderBottom": "1px solid #d6d6d6", + "padding": "6px", "fontWeight": "bold", "backgroundColor": "#1B96FF", "color": "white", diff --git a/merlion/dashboard/utils/log.py b/merlion/dashboard/utils/log.py index 597d7e184..16fd5ca51 100644 --- a/merlion/dashboard/utils/log.py +++ b/merlion/dashboard/utils/log.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/dashboard/utils/plot.py b/merlion/dashboard/utils/plot.py index c3b9232ba..7f9dd2b34 100644 --- a/merlion/dashboard/utils/plot.py +++ b/merlion/dashboard/utils/plot.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/evaluate/anomaly.py b/merlion/evaluate/anomaly.py index a5da0603b..156775ae8 100644 --- a/merlion/evaluate/anomaly.py +++ b/merlion/evaluate/anomaly.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -118,7 +118,7 @@ def f_beta(self, score_type: ScoreType = ScoreType.RevisedPointAdjusted, beta=1. prec_score_type = rec_score_type = score_type p = self.precision(prec_score_type) r = self.recall(rec_score_type) - return 0.0 if p == 0 or r == 0 else (1 + beta ** 2) * p * r / (beta ** 2 * p + r) + return 0.0 if p == 0 or r == 0 else (1 + beta**2) * p * r / (beta**2 * p + r) def mean_time_to_detect(self): t = np.mean(self.tp_detection_delays) if self.tp_detection_delays else 0 diff --git a/merlion/evaluate/base.py b/merlion/evaluate/base.py index 43a258a53..5fe7c0566 100644 --- a/merlion/evaluate/base.py +++ b/merlion/evaluate/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/evaluate/forecast.py b/merlion/evaluate/forecast.py index 6641d67b6..77b9bfe3c 100644 --- a/merlion/evaluate/forecast.py +++ b/merlion/evaluate/forecast.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/autoencoder.py b/merlion/models/anomaly/autoencoder.py index c6ea015ae..e673adb6a 100644 --- a/merlion/models/anomaly/autoencoder.py +++ b/merlion/models/anomaly/autoencoder.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/base.py b/merlion/models/anomaly/base.py index 7b181d4ac..49e3c99dd 100644 --- a/merlion/models/anomaly/base.py +++ b/merlion/models/anomaly/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/change_point/bocpd.py b/merlion/models/anomaly/change_point/bocpd.py index 63c687ca3..d3dba575d 100644 --- a/merlion/models/anomaly/change_point/bocpd.py +++ b/merlion/models/anomaly/change_point/bocpd.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/dagmm.py b/merlion/models/anomaly/dagmm.py index 55155589e..4ba1b4907 100644 --- a/merlion/models/anomaly/dagmm.py +++ b/merlion/models/anomaly/dagmm.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/dbl.py b/merlion/models/anomaly/dbl.py index afd97eb89..aae37aaaf 100644 --- a/merlion/models/anomaly/dbl.py +++ b/merlion/models/anomaly/dbl.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/deep_point_anomaly_detector.py b/merlion/models/anomaly/deep_point_anomaly_detector.py index 60a88f53b..3549507ed 100644 --- a/merlion/models/anomaly/deep_point_anomaly_detector.py +++ b/merlion/models/anomaly/deep_point_anomaly_detector.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/forecast_based/__init__.py b/merlion/models/anomaly/forecast_based/__init__.py index 96e7499f5..6824af204 100644 --- a/merlion/models/anomaly/forecast_based/__init__.py +++ b/merlion/models/anomaly/forecast_based/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/forecast_based/base.py b/merlion/models/anomaly/forecast_based/base.py index f01f1b931..19885e304 100644 --- a/merlion/models/anomaly/forecast_based/base.py +++ b/merlion/models/anomaly/forecast_based/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/forecast_based/mses.py b/merlion/models/anomaly/forecast_based/mses.py index 3f9130526..d1f45f137 100644 --- a/merlion/models/anomaly/forecast_based/mses.py +++ b/merlion/models/anomaly/forecast_based/mses.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/forecast_based/prophet.py b/merlion/models/anomaly/forecast_based/prophet.py index 0488ce530..3b3ce6d97 100644 --- a/merlion/models/anomaly/forecast_based/prophet.py +++ b/merlion/models/anomaly/forecast_based/prophet.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/isolation_forest.py b/merlion/models/anomaly/isolation_forest.py index df78b18c4..4a02b1f64 100644 --- a/merlion/models/anomaly/isolation_forest.py +++ b/merlion/models/anomaly/isolation_forest.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -29,7 +29,7 @@ class IsolationForestConfig(DetectorConfig): _default_transform = TransformSequence([DifferenceTransform(), Shingle(size=2, stride=1)]) - def __init__(self, max_n_samples: int = None, n_estimators: int = 100, **kwargs): + def __init__(self, max_n_samples: int = None, n_estimators: int = 100, n_jobs=-1, **kwargs): """ :param max_n_samples: Maximum number of samples to allow the isolation forest to train on. Specify ``None`` to use all samples in the @@ -38,6 +38,7 @@ def __init__(self, max_n_samples: int = None, n_estimators: int = 100, **kwargs) """ self.max_n_samples = 1.0 if max_n_samples is None else max_n_samples self.n_estimators = n_estimators + self.n_jobs = n_jobs # Isolation forest's uncalibrated scores are between 0 and 1 kwargs["max_score"] = 1.0 super().__init__(**kwargs) @@ -54,7 +55,7 @@ class IsolationForest(DetectorBase): def __init__(self, config: IsolationForestConfig): super().__init__(config) self.model = skl_IsolationForest( - max_samples=config.max_n_samples, n_estimators=config.n_estimators, random_state=0 + max_samples=config.max_n_samples, n_estimators=config.n_estimators, random_state=0, n_jobs=config.n_jobs ) @property diff --git a/merlion/models/anomaly/lstm_ed.py b/merlion/models/anomaly/lstm_ed.py index 4881cdf15..c408586e3 100644 --- a/merlion/models/anomaly/lstm_ed.py +++ b/merlion/models/anomaly/lstm_ed.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/random_cut_forest.py b/merlion/models/anomaly/random_cut_forest.py index f8ea4bcb1..e226518f8 100644 --- a/merlion/models/anomaly/random_cut_forest.py +++ b/merlion/models/anomaly/random_cut_forest.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/spectral_residual.py b/merlion/models/anomaly/spectral_residual.py index 9ff5cfc40..000334084 100644 --- a/merlion/models/anomaly/spectral_residual.py +++ b/merlion/models/anomaly/spectral_residual.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/stat_threshold.py b/merlion/models/anomaly/stat_threshold.py index e3669fb71..93a527bde 100644 --- a/merlion/models/anomaly/stat_threshold.py +++ b/merlion/models/anomaly/stat_threshold.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/vae.py b/merlion/models/anomaly/vae.py index fbef3cc54..2ea1a02ef 100644 --- a/merlion/models/anomaly/vae.py +++ b/merlion/models/anomaly/vae.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -143,7 +143,7 @@ def _train(self, train_data: pd.DataFrame, train_config=None) -> pd.DataFrame: x = torch.tensor(batch, dtype=torch.float, device=self.device) recon_x, mu, log_var, _ = self.model(x, None) recon_loss = loss_func(x, recon_x) - kld_loss = -0.5 * torch.mean(torch.sum(1 + log_var - mu ** 2 - log_var.exp(), dim=1), dim=0) + kld_loss = -0.5 * torch.mean(torch.sum(1 + log_var - mu**2 - log_var.exp(), dim=1), dim=0) loss = recon_loss + kld_loss * self.kld_weight optimizer.zero_grad() loss.backward() diff --git a/merlion/models/anomaly/windstats.py b/merlion/models/anomaly/windstats.py index 775e24994..3f74e3311 100644 --- a/merlion/models/anomaly/windstats.py +++ b/merlion/models/anomaly/windstats.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/anomaly/zms.py b/merlion/models/anomaly/zms.py index 97f400bf8..3eccdcc87 100644 --- a/merlion/models/anomaly/zms.py +++ b/merlion/models/anomaly/zms.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -84,7 +84,7 @@ def n_lags(self, n: int): the output dimension (number of lags) will change. """ self._n_lags = n - lags = [LagTransform(self.base ** k, pad=True) for k in range(n)] if n is not None else [] + lags = [LagTransform(self.base**k, pad=True) for k in range(n)] if n is not None else [] self.lags = TransformStack([Identity(), *lags]) self.normalize = MeanVarNormalize() diff --git a/merlion/models/automl/__init__.py b/merlion/models/automl/__init__.py index ca1bea52b..b591e1963 100644 --- a/merlion/models/automl/__init__.py +++ b/merlion/models/automl/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/automl/autoets.py b/merlion/models/automl/autoets.py index 7b797f397..0cc48e4ca 100644 --- a/merlion/models/automl/autoets.py +++ b/merlion/models/automl/autoets.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/automl/autoprophet.py b/merlion/models/automl/autoprophet.py index 4bc0882c9..0845af3fa 100644 --- a/merlion/models/automl/autoprophet.py +++ b/merlion/models/automl/autoprophet.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/automl/autosarima.py b/merlion/models/automl/autosarima.py index 374846a1f..a0a6ff649 100644 --- a/merlion/models/automl/autosarima.py +++ b/merlion/models/automl/autosarima.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/automl/base.py b/merlion/models/automl/base.py index 19f90d4df..a86cb2c53 100644 --- a/merlion/models/automl/base.py +++ b/merlion/models/automl/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/automl/search.py b/merlion/models/automl/search.py index 5c8016d86..704894c74 100644 --- a/merlion/models/automl/search.py +++ b/merlion/models/automl/search.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/automl/seasonality.py b/merlion/models/automl/seasonality.py index 6c4c289b3..7abe70bee 100644 --- a/merlion/models/automl/seasonality.py +++ b/merlion/models/automl/seasonality.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/base.py b/merlion/models/base.py index 9be2c4a1a..1cf7f3aea 100644 --- a/merlion/models/base.py +++ b/merlion/models/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/deep_base.py b/merlion/models/deep_base.py index 51f777d98..45155f908 100644 --- a/merlion/models/deep_base.py +++ b/merlion/models/deep_base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -76,7 +76,7 @@ def __init__( optimizer: Union[str, Optimizer] = Optimizer.Adam, loss_fn: Union[str, LossFunction] = LossFunction.mse, clip_gradient: Optional[float] = None, - use_gpu: bool = False, + use_gpu: bool = True, ts_encoding: Union[None, str] = "h", lr: float = 1e-4, weight_decay: float = 0.0, diff --git a/merlion/models/defaults.py b/merlion/models/defaults.py index 38096678a..ace36c58d 100644 --- a/merlion/models/defaults.py +++ b/merlion/models/defaults.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/ensemble/anomaly.py b/merlion/models/ensemble/anomaly.py index 5b45a5c92..40dadec70 100644 --- a/merlion/models/ensemble/anomaly.py +++ b/merlion/models/ensemble/anomaly.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/ensemble/base.py b/merlion/models/ensemble/base.py index 712375f50..cb17bed95 100644 --- a/merlion/models/ensemble/base.py +++ b/merlion/models/ensemble/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/ensemble/combine.py b/merlion/models/ensemble/combine.py index 10be1071d..0dd4d1956 100644 --- a/merlion/models/ensemble/combine.py +++ b/merlion/models/ensemble/combine.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/ensemble/forecast.py b/merlion/models/ensemble/forecast.py index 419fe4aad..9dfc7c9c5 100644 --- a/merlion/models/ensemble/forecast.py +++ b/merlion/models/ensemble/forecast.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/arima.py b/merlion/models/forecast/arima.py index e9d657e42..d24d2017a 100644 --- a/merlion/models/forecast/arima.py +++ b/merlion/models/forecast/arima.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/autoformer.py b/merlion/models/forecast/autoformer.py index 0469d79af..29f88b760 100644 --- a/merlion/models/forecast/autoformer.py +++ b/merlion/models/forecast/autoformer.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/base.py b/merlion/models/forecast/base.py index ceae77a43..dc34606ab 100644 --- a/merlion/models/forecast/base.py +++ b/merlion/models/forecast/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/deep_base.py b/merlion/models/forecast/deep_base.py index 37f64e215..df2d47d4b 100644 --- a/merlion/models/forecast/deep_base.py +++ b/merlion/models/forecast/deep_base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/ets.py b/merlion/models/forecast/ets.py index 4ecad2438..9a6f67e38 100644 --- a/merlion/models/forecast/ets.py +++ b/merlion/models/forecast/ets.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/etsformer.py b/merlion/models/forecast/etsformer.py index 443031668..16617f64c 100644 --- a/merlion/models/forecast/etsformer.py +++ b/merlion/models/forecast/etsformer.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/informer.py b/merlion/models/forecast/informer.py index ce0f0b0e4..4d594c7a3 100644 --- a/merlion/models/forecast/informer.py +++ b/merlion/models/forecast/informer.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/prophet.py b/merlion/models/forecast/prophet.py index 0d3804bbe..05762c901 100644 --- a/merlion/models/forecast/prophet.py +++ b/merlion/models/forecast/prophet.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/sarima.py b/merlion/models/forecast/sarima.py index eae63929b..d6487162f 100644 --- a/merlion/models/forecast/sarima.py +++ b/merlion/models/forecast/sarima.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/sklearn_base.py b/merlion/models/forecast/sklearn_base.py index acb025240..292dea05b 100644 --- a/merlion/models/forecast/sklearn_base.py +++ b/merlion/models/forecast/sklearn_base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/smoother.py b/merlion/models/forecast/smoother.py index 450b6e4ac..0594f92c4 100644 --- a/merlion/models/forecast/smoother.py +++ b/merlion/models/forecast/smoother.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -680,7 +680,7 @@ def loss_err(self, scale: int) -> float: stat = self.stats.get(scale) if stat is None or stat.loss.value is None: return np.inf - return (scale ** self.phi) * stat.loss.value * stat.loss_var.se + return (scale**self.phi) * stat.loss.value * stat.loss_var.se def delta_hat(self, scale: int) -> float: return self.velocity(scale) + self.accel_weight * self.acceleration(scale) diff --git a/merlion/models/forecast/transformer.py b/merlion/models/forecast/transformer.py index 6c9e2fb89..4297234ff 100644 --- a/merlion/models/forecast/transformer.py +++ b/merlion/models/forecast/transformer.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/trees.py b/merlion/models/forecast/trees.py index e38868c69..34a19bb18 100644 --- a/merlion/models/forecast/trees.py +++ b/merlion/models/forecast/trees.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/forecast/vector_ar.py b/merlion/models/forecast/vector_ar.py index db9cc0373..0c603ff08 100644 --- a/merlion/models/forecast/vector_ar.py +++ b/merlion/models/forecast/vector_ar.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/layers.py b/merlion/models/layers.py index 175d4877d..2b6e4d313 100644 --- a/merlion/models/layers.py +++ b/merlion/models/layers.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/utils/__init__.py b/merlion/models/utils/__init__.py index 63fa031d9..4cbc8021b 100644 --- a/merlion/models/utils/__init__.py +++ b/merlion/models/utils/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/utils/autosarima_utils.py b/merlion/models/utils/autosarima_utils.py index 9dc537852..579e28e3c 100644 --- a/merlion/models/utils/autosarima_utils.py +++ b/merlion/models/utils/autosarima_utils.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -187,7 +187,14 @@ def detect_maxiter_sarima_model(y, d, D, m, method, information_criterion, exog= maxiter = 10 ic = np.inf model_spec = sm.tsa.SARIMAX( - endog=y, exog=exog, order=order, seasonal_order=seasonal_order, trend="c", validate_specification=False, enforce_stationarity=False, enforce_invertibility=False + endog=y, + exog=exog, + order=order, + seasonal_order=seasonal_order, + trend="c", + validate_specification=False, + enforce_stationarity=False, + enforce_invertibility=False, ) with warnings.catch_warnings(): warnings.simplefilter("ignore") diff --git a/merlion/models/utils/early_stopping.py b/merlion/models/utils/early_stopping.py index 650514dd0..e167b59d8 100644 --- a/merlion/models/utils/early_stopping.py +++ b/merlion/models/utils/early_stopping.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/utils/nn_modules/__init__.py b/merlion/models/utils/nn_modules/__init__.py index dbdd65f6b..b7c737ffa 100644 --- a/merlion/models/utils/nn_modules/__init__.py +++ b/merlion/models/utils/nn_modules/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/utils/nn_modules/blocks.py b/merlion/models/utils/nn_modules/blocks.py index 5750d9110..fa25d1670 100644 --- a/merlion/models/utils/nn_modules/blocks.py +++ b/merlion/models/utils/nn_modules/blocks.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/utils/nn_modules/embed.py b/merlion/models/utils/nn_modules/embed.py index 80386a789..77e6ea12e 100644 --- a/merlion/models/utils/nn_modules/embed.py +++ b/merlion/models/utils/nn_modules/embed.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/utils/nn_modules/enc_dec_autoformer.py b/merlion/models/utils/nn_modules/enc_dec_autoformer.py index 048028aa5..b5f6887e9 100644 --- a/merlion/models/utils/nn_modules/enc_dec_autoformer.py +++ b/merlion/models/utils/nn_modules/enc_dec_autoformer.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/utils/nn_modules/enc_dec_etsformer.py b/merlion/models/utils/nn_modules/enc_dec_etsformer.py index b52ede317..c82723b1b 100644 --- a/merlion/models/utils/nn_modules/enc_dec_etsformer.py +++ b/merlion/models/utils/nn_modules/enc_dec_etsformer.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/utils/nn_modules/enc_dec_transformer.py b/merlion/models/utils/nn_modules/enc_dec_transformer.py index 758de5ce5..5a0fb5d7d 100644 --- a/merlion/models/utils/nn_modules/enc_dec_transformer.py +++ b/merlion/models/utils/nn_modules/enc_dec_transformer.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/utils/nn_modules/layers.py b/merlion/models/utils/nn_modules/layers.py index 044013875..40e520533 100644 --- a/merlion/models/utils/nn_modules/layers.py +++ b/merlion/models/utils/nn_modules/layers.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/utils/rolling_window_dataset.py b/merlion/models/utils/rolling_window_dataset.py index 962dea494..241311588 100644 --- a/merlion/models/utils/rolling_window_dataset.py +++ b/merlion/models/utils/rolling_window_dataset.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/models/utils/time_features.py b/merlion/models/utils/time_features.py index b663d8cd2..b56329766 100644 --- a/merlion/models/utils/time_features.py +++ b/merlion/models/utils/time_features.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/plot.py b/merlion/plot.py index b09e66fc4..822179722 100644 --- a/merlion/plot.py +++ b/merlion/plot.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/spark/dataset.py b/merlion/spark/dataset.py index f03c109ab..f8d210a34 100644 --- a/merlion/spark/dataset.py +++ b/merlion/spark/dataset.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/spark/pandas_udf.py b/merlion/spark/pandas_udf.py index 9ccdb5d6f..0abe4e3d5 100644 --- a/merlion/spark/pandas_udf.py +++ b/merlion/spark/pandas_udf.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -239,7 +239,7 @@ def reconciliation(pdf: pd.DataFrame, hier_matrix: np.ndarray, target_col: str): # P * W.diagonal() is a faster way to compute P @ W, since W is diagonal rec_errs = hier_matrix @ (P * W.diagonal()) # m by m # np.sum(rec_errs ** 2, axis=1) is a faster way to compute (rec_errs @ rec_errs.T).diagonal() - rec_errs = np.sqrt(np.sum(rec_errs ** 2, axis=1)) + rec_errs = np.sqrt(np.sum(rec_errs**2, axis=1)) # Replace original forecasts & errors with reconciled ones reconciled = pd.DataFrame(np.stack([rec, rec_errs], axis=1), index=pdf.index, columns=[target_col, errname]) diff --git a/merlion/transform/anomalize.py b/merlion/transform/anomalize.py index 725f57910..b4952ec3a 100644 --- a/merlion/transform/anomalize.py +++ b/merlion/transform/anomalize.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/transform/base.py b/merlion/transform/base.py index f0796d3d7..744c33058 100644 --- a/merlion/transform/base.py +++ b/merlion/transform/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/transform/factory.py b/merlion/transform/factory.py index 9fdb22f33..cf5639414 100644 --- a/merlion/transform/factory.py +++ b/merlion/transform/factory.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/transform/moving_average.py b/merlion/transform/moving_average.py index 46c85ea4a..51b68b7e3 100644 --- a/merlion/transform/moving_average.py +++ b/merlion/transform/moving_average.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/transform/normalize.py b/merlion/transform/normalize.py index 10b7d33fa..115a8c20e 100644 --- a/merlion/transform/normalize.py +++ b/merlion/transform/normalize.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/transform/resample.py b/merlion/transform/resample.py index a174b56b3..197cd6c75 100644 --- a/merlion/transform/resample.py +++ b/merlion/transform/resample.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/transform/sequence.py b/merlion/transform/sequence.py index 93938ee01..60d9c9085 100644 --- a/merlion/transform/sequence.py +++ b/merlion/transform/sequence.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/utils/__init__.py b/merlion/utils/__init__.py index 64e4f97d2..f3a94d19f 100644 --- a/merlion/utils/__init__.py +++ b/merlion/utils/__init__.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/utils/conj_priors.py b/merlion/utils/conj_priors.py index e0d2083b4..a73b8f0a6 100644 --- a/merlion/utils/conj_priors.py +++ b/merlion/utils/conj_priors.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -342,7 +342,7 @@ def mu_posterior(self, mu, return_rv=False, log=True): r""" The posterior for :math:`\mu` is :math:`\text{Student-t}_{2\alpha}(\mu_0, \beta / (n \alpha))` """ - scale = self.beta / (2 * self.alpha ** 2) + scale = self.beta / (2 * self.alpha**2) rv = student_t(loc=self.mu_0, scale=np.sqrt(scale), df=2 * self.alpha) return self._process_return(x=mu, rv=rv, return_rv=return_rv, log=log) @@ -358,7 +358,7 @@ def posterior(self, x, log=True, return_rv=False, return_updated=False): The posterior for :math:`x` is :math:`\text{Student-t}_{2\alpha}(\mu_0, (n+1) \beta / (n \alpha))` """ t, x_np = self.process_time_series(x) - scale = (self.beta * (2 * self.alpha + 1)) / (2 * self.alpha ** 2) + scale = (self.beta * (2 * self.alpha + 1)) / (2 * self.alpha**2) rv = student_t(loc=self.mu_0, scale=np.sqrt(scale), df=2 * self.alpha) ret = self._process_return(x=x_np, rv=rv, return_rv=return_rv, log=log) if return_updated: diff --git a/merlion/utils/data_io.py b/merlion/utils/data_io.py index 6ab770064..035638057 100644 --- a/merlion/utils/data_io.py +++ b/merlion/utils/data_io.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/utils/hts.py b/merlion/utils/hts.py index 3901e0451..40a399be4 100644 --- a/merlion/utils/hts.py +++ b/merlion/utils/hts.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/utils/istat.py b/merlion/utils/istat.py index cb792e460..3bfab39b9 100644 --- a/merlion/utils/istat.py +++ b/merlion/utils/istat.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -139,7 +139,7 @@ def __init__(self, ex_value: float = None, ex2_value: float = None, n: int = 0, \\text{Var}(x_i) = \\text{E}(x_i^2) - \\text{E}(x_i)^2 """ if ex_value is not None and ex2_value is not None: - super().__init__(value=ex2_value - ex_value ** 2, n=n) + super().__init__(value=ex2_value - ex_value**2, n=n) else: super().__init__() self.ex = self.mean_class(value=ex_value, n=n) @@ -149,20 +149,20 @@ def __init__(self, ex_value: float = None, ex2_value: float = None, n: int = 0, def add(self, x): self.n += 1 self.ex.add(x) - self.ex2.add(x ** 2) + self.ex2.add(x**2) def drop(self, x): if self.n == 0: return self.n -= 1 self.ex.drop(x) - self.ex2.drop(x ** 2) + self.ex2.drop(x**2) @property def true_value(self): if self.ex2.value is None or self.ex.value is None: return None - return max(0, self.ex2.value - self.ex.value ** 2) + return max(0, self.ex2.value - self.ex.value**2) @property def corrected_value(self): diff --git a/merlion/utils/misc.py b/merlion/utils/misc.py index f7b02bb11..ee42540aa 100644 --- a/merlion/utils/misc.py +++ b/merlion/utils/misc.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause @@ -197,7 +197,7 @@ def wrapper(self, *args, **kargs): class ProgressBar: - def __init__(self, total: int, length: int = 40, decimals: int = 1, fill: str = "█"): + def __init__(self, total: int, length: int = 40, decimals: int = 1, fill: str = "="): """ :param total: total iterations :param length: character length of bar @@ -218,7 +218,7 @@ def print(self, iteration, prefix, suffix, end=""): """ percent = ("{0:." + str(self.decimals) + "f}").format(100 * (iteration / float(self.total))) fill_len = self.length * iteration // self.total - bar = self.fill * fill_len + "-" * (self.length - fill_len) + bar = self.fill * fill_len + " " * (self.length - fill_len) print(f"\r{prefix} |{bar}| {percent}% {suffix}", end=end) if iteration >= self.total: print() diff --git a/merlion/utils/time_series.py b/merlion/utils/time_series.py index 15e8d41e5..4d9cc8fae 100644 --- a/merlion/utils/time_series.py +++ b/merlion/utils/time_series.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/merlion/utils/ts_generator.py b/merlion/utils/ts_generator.py index 554186031..c53d584a5 100644 --- a/merlion/utils/ts_generator.py +++ b/merlion/utils/ts_generator.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 salesforce.com, inc. +# Copyright (c) 2023 salesforce.com, inc. # All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause diff --git a/setup.py b/setup.py index 50af63fcc..16a606e86 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ def read_file(fname): setup( name="salesforce-merlion", - version="2.0.1", + version="2.0.2", author=", ".join(read_file("AUTHORS.md").split("\n")), author_email="abhatnagar@salesforce.com", description="Merlion: A Machine Learning Framework for Time Series Intelligence",