From 1fa8ac9ba5163537e973316fa6fa2f701a11cfcb Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 15 Mar 2025 01:38:39 -0400 Subject: [PATCH 01/18] swap mean_squared_error with tensorflow.losses.mse --- .github/workflows/tests.yml | 12 ++++++------ README.md | 2 +- .../primitives_pipelines/primitives/DenseSeq2Seq.rst | 2 +- .../primitives_pipelines/primitives/LSTMSeq2Seq.rst | 2 +- .../primitives/LSTMTimeSeriesRegressor.rst | 2 +- .../jsons/keras.Sequential.DenseSeq2Seq.json | 2 +- .../jsons/keras.Sequential.LSTMSeq2Seq.json | 2 +- .../keras.Sequential.LTCTimeSeriesRegressor.json | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9fe6deca..ff2c1a6b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] os: [ubuntu-latest] steps: - uses: actions/checkout@v1 @@ -50,7 +50,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v1 @@ -68,7 +68,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v1 @@ -86,7 +86,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.11'] + python-version: ['3.11', '3.12'] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v1 @@ -125,7 +125,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] os: [ubuntu-latest, macos-latest, windows-latest] exclude: - os: windows-latest @@ -148,7 +148,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.11'] + python-version: ['3.11', '3.12'] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v1 diff --git a/README.md b/README.md index cad59efa..e57ba737 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@

[![Development Status](https://img.shields.io/badge/Development%20Status-2%20--%20Pre--Alpha-yellow)](https://pypi.org/search/?c=Development+Status+%3A%3A+2+-+Pre-Alpha) -[![Python](https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue)](https://badge.fury.io/py/orion-ml) +[![Python](https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)](https://badge.fury.io/py/orion-ml) [![PyPi Shield](https://img.shields.io/pypi/v/orion-ml.svg)](https://pypi.python.org/pypi/orion-ml) [![Tests](https://github.com/sintel-dev/Orion/workflows/Run%20Tests/badge.svg)](https://github.com/sintel-dev/Orion/actions?query=workflow%3A%22Run+Tests%22+branch%3Amaster) [![Downloads](https://pepy.tech/badge/orion-ml)](https://pepy.tech/project/orion-ml) diff --git a/docs/user_guides/primitives_pipelines/primitives/DenseSeq2Seq.rst b/docs/user_guides/primitives_pipelines/primitives/DenseSeq2Seq.rst index ee7be16d..0aeb6f88 100644 --- a/docs/user_guides/primitives_pipelines/primitives/DenseSeq2Seq.rst +++ b/docs/user_guides/primitives_pipelines/primitives/DenseSeq2Seq.rst @@ -29,7 +29,7 @@ argument type description ``input_shape`` ``tuple`` tuple denoting the shape of an input sample ``target_shape`` ``tuple`` tuple denoting the shape of an output sample ``optimizer`` ``str`` string (name of optimizer) or optimizer instance. Default is ``keras.optimizers.Adam`` - ``loss`` ``str`` string (name of the objective function) or an objective function instance. Default is ``keras.losses.mean_squared_error`` + ``loss`` ``str`` string (name of the objective function) or an objective function instance. Default is ``tensorflow.losses.mse`` ``metrics`` ``list`` list of metrics to be evaluated by the model during training and testing. Default is ["mse"] ``return_seqeunces`` ``bool`` whether to return the last output in the output sequence, or the full sequence. Default is False ``layers`` ``list`` list of keras layers which are the basic building blocks of a neural network diff --git a/docs/user_guides/primitives_pipelines/primitives/LSTMSeq2Seq.rst b/docs/user_guides/primitives_pipelines/primitives/LSTMSeq2Seq.rst index dd3c1516..37b965e5 100644 --- a/docs/user_guides/primitives_pipelines/primitives/LSTMSeq2Seq.rst +++ b/docs/user_guides/primitives_pipelines/primitives/LSTMSeq2Seq.rst @@ -29,7 +29,7 @@ argument type description ``input_shape`` ``tuple`` tuple denoting the shape of an input sample ``target_shape`` ``tuple`` tuple denoting the shape of an output sample ``optimizer`` ``str`` string (name of optimizer) or optimizer instance. Default is ``keras.optimizers.Adam`` - ``loss`` ``str`` string (name of the objective function) or an objective function instance. Default is ``keras.losses.mean_squared_error`` + ``loss`` ``str`` string (name of the objective function) or an objective function instance. Default is ``tensorflow.losses.mse`` ``metrics`` ``list`` list of metrics to be evaluated by the model during training and testing. Default is ["mse"] ``return_seqeunces`` ``bool`` whether to return the last output in the output sequence, or the full sequence. Default is False ``layers`` ``list`` list of keras layers which are the basic building blocks of a neural network diff --git a/docs/user_guides/primitives_pipelines/primitives/LSTMTimeSeriesRegressor.rst b/docs/user_guides/primitives_pipelines/primitives/LSTMTimeSeriesRegressor.rst index d5ca166f..495dd959 100644 --- a/docs/user_guides/primitives_pipelines/primitives/LSTMTimeSeriesRegressor.rst +++ b/docs/user_guides/primitives_pipelines/primitives/LSTMTimeSeriesRegressor.rst @@ -28,7 +28,7 @@ argument type description ``input_shape`` ``tuple`` tuple denoting the shape of an input sample ``dense_units`` ``int`` number of values ahead to predict (target size). Default is 1. ``optimizer`` ``str`` string (name of optimizer) or optimizer instance. Default is ``keras.optimizers.Adam`` - ``loss`` ``str`` string (name of the objective function) or an objective function instance. Default is ``keras.losses.mean_squared_error`` + ``loss`` ``str`` string (name of the objective function) or an objective function instance. Default is ``tensorflow.losses.mse`` ``metrics`` ``list`` list of metrics to be evaluated by the model during training and testing. Default is ["mse"] ``return_seqeunces`` ``bool`` whether to return the last output in the output sequence, or the full sequence. Default is False ``layers`` ``list`` list of keras layers which are the basic building blocks of a neural network diff --git a/orion/primitives/jsons/keras.Sequential.DenseSeq2Seq.json b/orion/primitives/jsons/keras.Sequential.DenseSeq2Seq.json index c84d8806..d46c109f 100644 --- a/orion/primitives/jsons/keras.Sequential.DenseSeq2Seq.json +++ b/orion/primitives/jsons/keras.Sequential.DenseSeq2Seq.json @@ -92,7 +92,7 @@ }, "loss": { "type": "str", - "default": "tensorflow.keras.losses.mean_squared_error" + "default": "tensorflow.losses.mse" }, "metrics": { "type": "list", diff --git a/orion/primitives/jsons/keras.Sequential.LSTMSeq2Seq.json b/orion/primitives/jsons/keras.Sequential.LSTMSeq2Seq.json index 31242807..6069d47b 100644 --- a/orion/primitives/jsons/keras.Sequential.LSTMSeq2Seq.json +++ b/orion/primitives/jsons/keras.Sequential.LSTMSeq2Seq.json @@ -92,7 +92,7 @@ }, "loss": { "type": "str", - "default": "tensorflow.keras.losses.mean_squared_error" + "default": "tensorflow.losses.mse" }, "metrics": { "type": "list", diff --git a/orion/primitives/jsons/keras.Sequential.LTCTimeSeriesRegressor.json b/orion/primitives/jsons/keras.Sequential.LTCTimeSeriesRegressor.json index e49bfc64..45964528 100644 --- a/orion/primitives/jsons/keras.Sequential.LTCTimeSeriesRegressor.json +++ b/orion/primitives/jsons/keras.Sequential.LTCTimeSeriesRegressor.json @@ -92,7 +92,7 @@ }, "loss": { "type": "str", - "default": "tensorflow.keras.losses.mean_squared_error" + "default": "tensorflow.losses.mse" }, "metrics": { "type": "list", @@ -149,7 +149,7 @@ } }, { - "class": "ncps.tf.LTC", + "class": "ncps.keras.LTC", "parameters": { "units": { "class": "ncps.wirings.AutoNCP", From 4fa07c31a0335c622c93636a642db6a079f5b408 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 15 Mar 2025 01:39:09 -0400 Subject: [PATCH 02/18] adjust layer check --- orion/primitives/adapters/ncps.py | 2 +- orion/primitives/aer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/orion/primitives/adapters/ncps.py b/orion/primitives/adapters/ncps.py index 097f6224..037a2542 100644 --- a/orion/primitives/adapters/ncps.py +++ b/orion/primitives/adapters/ncps.py @@ -8,7 +8,7 @@ def build_layer(layer, hyperparameters): layer_class = import_object(layer['class']) layer_kwargs = layer['parameters'].copy() - if issubclass(layer_class, tf.keras.layers.Wrapper): + if issubclass(layer_class, tf.keras.layers.Layer) and 'layer' in layer_kwargs: layer_kwargs['layer'] = build_layer(layer_kwargs['layer'], hyperparameters) elif issubclass(layer_class, tf.keras.layers.RNN) and isinstance(layer_kwargs['units'], dict): layer_kwargs['units'] = build_layer(layer_kwargs['units'], hyperparameters) diff --git a/orion/primitives/aer.py b/orion/primitives/aer.py index 94e94735..f202d4d1 100644 --- a/orion/primitives/aer.py +++ b/orion/primitives/aer.py @@ -19,7 +19,7 @@ def build_layer(layer: dict, hyperparameters: dict): layer_class = import_object(layer['class']) layer_kwargs = layer['parameters'].copy() # TODO: Upgrade to using tf.keras.layers.Wrapper in mlprimitives. - if issubclass(layer_class, tf.keras.layers.Wrapper): + if issubclass(layer_class, tf.keras.layers.Layer) and 'layer' in layer_kwargs: layer_kwargs['layer'] = build_layer(layer_kwargs['layer'], hyperparameters) for key, value in layer_kwargs.items(): if isinstance(value, str): From 48fe6eab281d9a5c80255cfa8dba6e26c2b57ec8 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 15 Mar 2025 01:39:54 -0400 Subject: [PATCH 03/18] update functionality to remove warnings / deprecation --- orion/primitives/timeseries_errors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orion/primitives/timeseries_errors.py b/orion/primitives/timeseries_errors.py index 4fde3863..715ca6a5 100644 --- a/orion/primitives/timeseries_errors.py +++ b/orion/primitives/timeseries_errors.py @@ -91,9 +91,9 @@ def _area_error(y, y_hat, score_window=10): An array of area error. """ smooth_y = pd.Series(y).rolling( - score_window, center=True, min_periods=score_window // 2).apply(integrate.trapz) + score_window, center=True, min_periods=score_window // 2).apply(integrate.trapezoid) smooth_y_hat = pd.Series(y_hat).rolling( - score_window, center=True, min_periods=score_window // 2).apply(integrate.trapz) + score_window, center=True, min_periods=score_window // 2).apply(integrate.trapezoid) errors = abs(smooth_y - smooth_y_hat) From eecc7e8a892995c900ed413119c92e546f204138 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 15 Mar 2025 01:40:56 -0400 Subject: [PATCH 04/18] remove support for python 3.8 --- README.md | 2 +- setup.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e57ba737..a3a5454a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@

[![Development Status](https://img.shields.io/badge/Development%20Status-2%20--%20Pre--Alpha-yellow)](https://pypi.org/search/?c=Development+Status+%3A%3A+2+-+Pre-Alpha) -[![Python](https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)](https://badge.fury.io/py/orion-ml) +[![Python](https://img.shields.io/badge/Python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)](https://badge.fury.io/py/orion-ml) [![PyPi Shield](https://img.shields.io/pypi/v/orion-ml.svg)](https://pypi.python.org/pypi/orion-ml) [![Tests](https://github.com/sintel-dev/Orion/workflows/Run%20Tests/badge.svg)](https://github.com/sintel-dev/Orion/actions?query=workflow%3A%22Run+Tests%22+branch%3Amaster) [![Downloads](https://pepy.tech/badge/orion-ml)](https://pepy.tech/project/orion-ml) diff --git a/setup.py b/setup.py index 4bc268e1..4c8d21ad 100644 --- a/setup.py +++ b/setup.py @@ -17,15 +17,14 @@ install_requires = [ - 'tensorflow>=2.2,<2.15', + 'tensorflow>=2.15,<2.20', 'numpy>=1.17.5,<2', 'pandas>=1,<3', 'numba>=0.48,<0.60', - 's3fs>=0.2.2,<0.5', - 'mlblocks>=0.6.2,<0.7', - 'ml-stars>=0.2.1.dev0,<0.4', - 'scikit-learn>=0.22.1,<2', - 'scipy<1.14', + 'mlblocks>=0.6.2,<0.8', + 'ml-stars>=0.2.2,<0.4', + 'scikit-learn>=0.22.1,<1.6', + 'scipy>=1.6.1,<2', 'tabulate>=0.8.3,<0.9', 'pyts>=0.11,<0.14', 'torch>=1.4,<2.6', @@ -65,7 +64,7 @@ # general 'pip>=9.0.1', 'bumpversion>=0.5.3,<0.6', - 'watchdog>=0.8.3,<0.11', + 'watchdog>=0.8.3,<5', # docs 'docutils>=0.12,<0.18', @@ -114,10 +113,10 @@ 'License :: OSI Approved :: MIT License', 'Natural Language :: English', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ], description="Orion is a machine learning library built for unsupervised time series anomaly detection.", entry_points={ @@ -142,7 +141,7 @@ long_description_content_type='text/markdown', name='orion-ml', packages=find_packages(include=['orion', 'orion.*']), - python_requires='>=3.8,<3.12', + python_requires='>=3.9,<3.13', setup_requires=setup_requires, test_suite='tests', tests_require=tests_require, From 0e7592d3f326656e1543b6c4a3b2f7106b9ee98a Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 15 Mar 2025 01:41:10 -0400 Subject: [PATCH 05/18] update --- .../lstm_dynamic_threshold/lstm_dynamic_threshold.json | 3 ++- orion/primitives/timeseries_anomalies.py | 2 +- tests/unit/primitives/adapters/test_ncps.py | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/orion/pipelines/verified/lstm_dynamic_threshold/lstm_dynamic_threshold.json b/orion/pipelines/verified/lstm_dynamic_threshold/lstm_dynamic_threshold.json index 4d87efd6..35e05b2c 100644 --- a/orion/pipelines/verified/lstm_dynamic_threshold/lstm_dynamic_threshold.json +++ b/orion/pipelines/verified/lstm_dynamic_threshold/lstm_dynamic_threshold.json @@ -25,7 +25,8 @@ "window_size": 250 }, "keras.Sequential.LSTMTimeSeriesRegressor": { - "epochs": 35 + "epochs": 35, + "loss": "tensorflow.losses.mse" }, "orion.primitives.timeseries_anomalies.find_anomalies#1": { "window_size_portion": 0.33, diff --git a/orion/primitives/timeseries_anomalies.py b/orion/primitives/timeseries_anomalies.py index 023b7039..f19b2373 100644 --- a/orion/primitives/timeseries_anomalies.py +++ b/orion/primitives/timeseries_anomalies.py @@ -193,7 +193,7 @@ def _find_sequences(errors, epsilon, anomaly_padding): for idx in index_above.flatten(): above[max(0, idx - anomaly_padding):min(idx + anomaly_padding + 1, len(above))] = True - shift = above.shift(1).fillna(False) + shift = above.shift(1).astype('boolean').fillna(False) change = above != shift if above.all(): diff --git a/tests/unit/primitives/adapters/test_ncps.py b/tests/unit/primitives/adapters/test_ncps.py index 5f989f59..bf630c41 100644 --- a/tests/unit/primitives/adapters/test_ncps.py +++ b/tests/unit/primitives/adapters/test_ncps.py @@ -47,7 +47,7 @@ def test_build_layer_bidirectional(): def test_build_layer_ltc(): # Setup layer = { - 'class': 'ncps.tf.LTC', + 'class': 'ncps.keras.LTC', 'parameters': { 'units': { 'class': 'ncps.wirings.AutoNCP', @@ -63,7 +63,7 @@ def test_build_layer_ltc(): built = build_layer(layer, {}) # Assert - assert isinstance(built, ncps.tf.LTC) + assert isinstance(built, ncps.keras.LTC) def test__build_model(): @@ -76,7 +76,7 @@ def test__build_model(): } } ] - loss = 'tensorflow.keras.losses.mean_squared_error' + loss = 'tensorflow.losses.mse' optimizer = 'tensorflow.keras.optimizers.Adam' # Run @@ -111,7 +111,7 @@ def test_ncps_linear(build_mock): } } ] - loss = 'tensorflow.keras.losses.mean_squared_error' + loss = 'tensorflow.losses.mse' optimizer = 'tensorflow.keras.optimizers.Adam' ncps = NCPS(layers, loss, optimizer, False, batch_size=1) From 9276ffa8677976fdc4707aea88f2a6483d0b6e56 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 15 Mar 2025 02:53:19 -0400 Subject: [PATCH 06/18] remove python 3.8 from tests --- .github/workflows/tests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ff2c1a6b..29956fc2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.8] + python-version: [3.10] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v1 @@ -32,7 +32,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12'] os: [ubuntu-latest] steps: - uses: actions/checkout@v1 @@ -50,7 +50,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12'] os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v1 @@ -68,7 +68,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12'] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v1 @@ -105,7 +105,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8'] + python-version: ['3.9'] os: [macos-13] steps: - uses: actions/checkout@v4 @@ -125,7 +125,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12'] os: [ubuntu-latest, macos-latest, windows-latest] exclude: - os: windows-latest From 6d0ab4b9c9b6b3cd468debbf15a0aa44848acf1a Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 15 Mar 2025 03:16:50 -0400 Subject: [PATCH 07/18] update minimum --- setup.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 4c8d21ad..36bdb00d 100644 --- a/setup.py +++ b/setup.py @@ -17,17 +17,17 @@ install_requires = [ - 'tensorflow>=2.15,<2.20', - 'numpy>=1.17.5,<2', - 'pandas>=1,<3', - 'numba>=0.48,<0.60', + 'tensorflow>=2.16.1,<2.20', + 'numpy>=1.23.5,<2', + 'pandas>=1.4.0,<3', + 'numba>=0.56.2,<0.7', 'mlblocks>=0.6.2,<0.8', 'ml-stars>=0.2.2,<0.4', - 'scikit-learn>=0.22.1,<1.6', - 'scipy>=1.6.1,<2', + 'scikit-learn>=1.1.0,<1.6', + 'scipy>=1.8.0,<2', 'tabulate>=0.8.3,<0.9', 'pyts>=0.11,<0.14', - 'torch>=1.4,<2.6', + 'torch>=1.9.0,<2.6', 'azure-cognitiveservices-anomalydetector>=0.3,<0.4', 'xlsxwriter>=1.3.6,<1.4', 'tqdm>=4.36.1', From 4084bd7eb80bb4ffe5f7cc8cf27bcad418113d7c Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 15 Mar 2025 03:18:55 -0400 Subject: [PATCH 08/18] fix numba cap --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 36bdb00d..c6bcabd6 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ 'tensorflow>=2.16.1,<2.20', 'numpy>=1.23.5,<2', 'pandas>=1.4.0,<3', - 'numba>=0.56.2,<0.7', + 'numba>=0.56.2,<0.70', 'mlblocks>=0.6.2,<0.8', 'ml-stars>=0.2.2,<0.4', 'scikit-learn>=1.1.0,<1.6', From 62d08f09c5e17e516aa0d339b1a8c4e0ab3e01b8 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 15 Mar 2025 03:21:32 -0400 Subject: [PATCH 09/18] keep python 3.10 --- .github/workflows/docs.yml | 2 +- .github/workflows/latest-dependencies.yml | 4 ++-- .github/workflows/tests.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index eb5788ce..d0e66672 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,7 +14,7 @@ jobs: - name: Python uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: '3.10' - name: Build run: | diff --git a/.github/workflows/latest-dependencies.yml b/.github/workflows/latest-dependencies.yml index c0418a9f..9f241c8c 100644 --- a/.github/workflows/latest-dependencies.yml +++ b/.github/workflows/latest-dependencies.yml @@ -8,10 +8,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: '3.10' - name: Install package run: | pip install --upgrade pip diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 29956fc2..0b553caa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.10] + python-version: ['3.10'] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v1 From 6e6f7c06ea08f962d6a41019b66c9836ab9849c0 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 15 Mar 2025 04:07:41 -0400 Subject: [PATCH 10/18] fix docs --- docs/conf.py | 3 +- .../primitives/LSTMTimeSeriesRegressor.rst | 2 +- setup.py | 29 ++++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 480f087f..365759de 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -31,7 +31,6 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ - 'm2r2', 'nbsphinx', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', @@ -96,7 +95,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/docs/user_guides/primitives_pipelines/primitives/LSTMTimeSeriesRegressor.rst b/docs/user_guides/primitives_pipelines/primitives/LSTMTimeSeriesRegressor.rst index 495dd959..c669a695 100644 --- a/docs/user_guides/primitives_pipelines/primitives/LSTMTimeSeriesRegressor.rst +++ b/docs/user_guides/primitives_pipelines/primitives/LSTMTimeSeriesRegressor.rst @@ -53,7 +53,7 @@ argument type description X = np.array([1] * 100).reshape(1, -1, 1) y = np.array([[1]]) primitive = load_primitive('keras.Sequential.LSTMTimeSeriesRegressor', - arguments={"X": X, "y": y, "input_shape":(100, 1), "batch_size": 1, "validation_split": 0}) + arguments={"X": X, "y": y, "input_shape":(100, 1), "batch_size": 1, "validation_split": 0, "loss": "tensorflow.losses.mse"}) primitive.fit() primitive.produce(X=X) diff --git a/setup.py b/setup.py index c6bcabd6..a226c085 100644 --- a/setup.py +++ b/setup.py @@ -67,23 +67,24 @@ 'watchdog>=0.8.3,<5', # docs - 'docutils>=0.12,<0.18', - 'm2r2>=0.2.5,<0.3', - 'nbsphinx>=0.5.0,<0.7', - 'Sphinx>=3,<3.3', - 'pydata-sphinx-theme<0.5', - 'markupsafe<2.1.0', - 'ipython>=6.5,<9', - 'Jinja2>=2,<3', + 'docutils>=0.12,<1', + # 'm2r2>=0.2.5,<0.3', + 'nbsphinx>=0.5.0,<1', + 'sphinx_toolbox>=2.5,<4', + 'Sphinx>=3,<8', + 'pydata-sphinx-theme<1', + 'markupsafe<3', + 'ipython>=6.5,<12', + 'Jinja2>=2,<4', # fails on Sphinx < v3.4 - 'alabaster<=0.7.12', + # 'alabaster<=0.7.12', # fails on Sphins < v5.0 - 'sphinxcontrib-applehelp<1.0.8', - 'sphinxcontrib-devhelp<1.0.6', - 'sphinxcontrib-htmlhelp<2.0.5', - 'sphinxcontrib-serializinghtml<1.1.10', - 'sphinxcontrib-qthelp<1.0.7', + # 'sphinxcontrib-applehelp<1.0.8', + # 'sphinxcontrib-devhelp<1.0.6', + # 'sphinxcontrib-htmlhelp<2.0.5', + # 'sphinxcontrib-serializinghtml<1.1.10', + # 'sphinxcontrib-qthelp<1.0.7', # style check 'flake8>=3.7.7,<4', From 277ad9b52fa5c0fc87be2173ce2bf6100463e20a Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Mon, 17 Mar 2025 14:31:24 -0400 Subject: [PATCH 11/18] one build_layer function --- orion/primitives/aer.py | 13 +------------ orion/primitives/tadgan.py | 15 +-------------- orion/primitives/utils.py | 16 ++++++++++++++++ orion/primitives/vae.py | 16 +++------------- setup.py | 1 + 5 files changed, 22 insertions(+), 39 deletions(-) create mode 100644 orion/primitives/utils.py diff --git a/orion/primitives/aer.py b/orion/primitives/aer.py index f202d4d1..f44b15ea 100644 --- a/orion/primitives/aer.py +++ b/orion/primitives/aer.py @@ -11,22 +11,11 @@ from tensorflow.keras.models import Model from orion.primitives.timeseries_errors import reconstruction_errors, regression_errors +from orion.primitives.utils import build_layer LOGGER = logging.getLogger(__name__) -def build_layer(layer: dict, hyperparameters: dict): - layer_class = import_object(layer['class']) - layer_kwargs = layer['parameters'].copy() - # TODO: Upgrade to using tf.keras.layers.Wrapper in mlprimitives. - if issubclass(layer_class, tf.keras.layers.Layer) and 'layer' in layer_kwargs: - layer_kwargs['layer'] = build_layer(layer_kwargs['layer'], hyperparameters) - for key, value in layer_kwargs.items(): - if isinstance(value, str): - layer_kwargs[key] = hyperparameters.get(value, value) - return layer_class(**layer_kwargs) - - class AER(object): """Autoencoder with bi-directional regression for time series anomaly detection. diff --git a/orion/primitives/tadgan.py b/orion/primitives/tadgan.py index 5f3d9d14..4ade0b34 100644 --- a/orion/primitives/tadgan.py +++ b/orion/primitives/tadgan.py @@ -14,6 +14,7 @@ from tensorflow.keras import Model from orion.primitives.timeseries_errors import reconstruction_errors +from orion.primitives.utils import build_layer LOGGER = logging.getLogger(__name__) tf.keras.backend.set_floatx('float64') @@ -25,20 +26,6 @@ ] -def build_layer(layer: dict, hyperparameters: dict): - layer_class = import_object(layer['class']) - layer_kwargs = layer['parameters'].copy() - # TODO: Upgrade to using tf.keras.layers.Wrapper in mlprimitives. - if issubclass(layer_class, tf.keras.layers.Wrapper): - layer_kwargs['layer'] = build_layer(layer_kwargs['layer'], hyperparameters) - - for key, value in layer_kwargs.items(): - if isinstance(value, str): - layer_kwargs[key] = hyperparameters.get(value, value) - - return layer_class(**layer_kwargs) - - class TadGAN: """TadGAN model for time series reconstruction. diff --git a/orion/primitives/utils.py b/orion/primitives/utils.py new file mode 100644 index 00000000..b4fcfc76 --- /dev/null +++ b/orion/primitives/utils.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +import tensorflow as tf +from mlstars.utils import import_object + + +def build_layer(layer: dict, hyperparameters: dict): + layer_class = import_object(layer['class']) + layer_kwargs = layer['parameters'].copy() + # TODO: tf.keras.layers.Wrapper deprecated, Bidirectional inheret from Layer + if issubclass(layer_class, tf.keras.layers.Layer) and 'layer' in layer_kwargs: + layer_kwargs['layer'] = build_layer(layer_kwargs['layer'], hyperparameters) + for key, value in layer_kwargs.items(): + if isinstance(value, str): + layer_kwargs[key] = hyperparameters.get(value, value) + return layer_class(**layer_kwargs) \ No newline at end of file diff --git a/orion/primitives/vae.py b/orion/primitives/vae.py index 26334d63..626bf4e8 100644 --- a/orion/primitives/vae.py +++ b/orion/primitives/vae.py @@ -16,19 +16,9 @@ from tensorflow.keras.layers import Input from tensorflow.keras.models import Model -LOGGER = logging.getLogger(__name__) - +from orion.primitives.utils import build_layer -def build_layer(layer: dict, hyperparameters: dict): - layer_class = import_object(layer['class']) - layer_kwargs = layer['parameters'].copy() - # TODO: Upgrade to using tf.keras.layers.Wrapper in mlprimitives. - if issubclass(layer_class, tf.keras.layers.Wrapper): - layer_kwargs['layer'] = build_layer(layer_kwargs['layer'], hyperparameters) - for key, value in layer_kwargs.items(): - if isinstance(value, str): - layer_kwargs[key] = hyperparameters.get(value, value) - return layer_class(**layer_kwargs) +LOGGER = logging.getLogger(__name__) class VAE(object): @@ -127,7 +117,7 @@ def __init__(self, layers_encoder: list, layers_generator: list, optimizer: str, self.epochs = epochs self.batch_size = batch_size self.optimizer = import_object(optimizer)(learning_rate) - self.mse_loss = tf.keras.losses.MeanSquaredError() + self.mse_loss = tf.losses.mse self.shuffle = shuffle self.verbose = verbose self.hyperparameters = hyperparameters diff --git a/setup.py b/setup.py index a226c085..0c8b7210 100644 --- a/setup.py +++ b/setup.py @@ -76,6 +76,7 @@ 'markupsafe<3', 'ipython>=6.5,<12', 'Jinja2>=2,<4', + 'pickleshare', # ipython sphinx # fails on Sphinx < v3.4 # 'alabaster<=0.7.12', From 492d117dfeda5148b166e7f687f2a363eea8494c Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Wed, 19 Mar 2025 16:28:36 -0400 Subject: [PATCH 12/18] updated vae --- orion/primitives/vae.py | 18 +++++++++++++----- setup.py | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/orion/primitives/vae.py b/orion/primitives/vae.py index 626bf4e8..bb60d919 100644 --- a/orion/primitives/vae.py +++ b/orion/primitives/vae.py @@ -21,6 +21,14 @@ LOGGER = logging.getLogger(__name__) +class KLDivergenceLayer(tf.keras.layers.Layer): + def call(self, inputs): + z_log_sigma, z_mean = inputs + kl_loss = -0.5 * K.mean(1 + z_log_sigma - K.square(z_mean) - K.exp(z_log_sigma), axis=-1) + self.add_loss(kl_loss) + return inputs + + class VAE(object): """VAE model for time series reconstruction. @@ -117,7 +125,7 @@ def __init__(self, layers_encoder: list, layers_generator: list, optimizer: str, self.epochs = epochs self.batch_size = batch_size self.optimizer = import_object(optimizer)(learning_rate) - self.mse_loss = tf.losses.mse + self.mse_loss = tf.keras.losses.MeanSquaredError() self.shuffle = shuffle self.verbose = verbose self.hyperparameters = hyperparameters @@ -170,13 +178,13 @@ def _build_vae(self, **kwargs): h = self.encoder(x) z_mean = tf.keras.layers.Dense(self.latent_dim)(h) z_log_sigma = tf.keras.layers.Dense(self.latent_dim)(h) + KLDivergenceLayer()([z_log_sigma, z_mean]) # kl loss z = tf.keras.layers.Lambda(self._sampling)([z_mean, z_log_sigma]) y_ = self.generator(z) self.vae_model = Model([x, y], y_) - self.vae_model.add_loss(self._vae_loss(y, y_, z_log_sigma, z_mean)) - self.vae_model.compile(optimizer=self.optimizer) + self.vae_model.compile(loss='mse', optimizer=self.optimizer) def fit(self, X: np.ndarray, y: np.ndarray, **kwargs): """Fit the model. @@ -201,11 +209,11 @@ def fit(self, X: np.ndarray, y: np.ndarray, **kwargs): for callback in self.callbacks ] - self.fit_history = self.vae_model.fit((X, y), + self.fit_history = self.vae_model.fit((X, y), y, batch_size=self.batch_size, epochs=self.epochs, shuffle=self.shuffle, - verbose=self.verbose, + verbose=True, callbacks=callbacks, validation_split=self.validation_split, ) diff --git a/setup.py b/setup.py index 0c8b7210..4136160a 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ install_requires = [ + 'Keras>=3,<4', 'tensorflow>=2.16.1,<2.20', 'numpy>=1.23.5,<2', 'pandas>=1.4.0,<3', From 36c862f3a2b9ba7e159f8c6cb50697b5010d2ef0 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 22 Mar 2025 00:57:27 -0400 Subject: [PATCH 13/18] update minimum tests --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0b553caa..9e8f3a04 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -106,7 +106,7 @@ jobs: strategy: matrix: python-version: ['3.9'] - os: [macos-13] + os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} From 6ab74501afb8fd4c7562d6278f63d096d593fa89 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 22 Mar 2025 00:58:25 -0400 Subject: [PATCH 14/18] fix lint --- orion/primitives/utils.py | 2 +- orion/primitives/vae.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/orion/primitives/utils.py b/orion/primitives/utils.py index b4fcfc76..bc1db171 100644 --- a/orion/primitives/utils.py +++ b/orion/primitives/utils.py @@ -13,4 +13,4 @@ def build_layer(layer: dict, hyperparameters: dict): for key, value in layer_kwargs.items(): if isinstance(value, str): layer_kwargs[key] = hyperparameters.get(value, value) - return layer_class(**layer_kwargs) \ No newline at end of file + return layer_class(**layer_kwargs) diff --git a/orion/primitives/vae.py b/orion/primitives/vae.py index bb60d919..0bebe7ff 100644 --- a/orion/primitives/vae.py +++ b/orion/primitives/vae.py @@ -27,7 +27,7 @@ def call(self, inputs): kl_loss = -0.5 * K.mean(1 + z_log_sigma - K.square(z_mean) - K.exp(z_log_sigma), axis=-1) self.add_loss(kl_loss) return inputs - + class VAE(object): """VAE model for time series reconstruction. @@ -178,7 +178,7 @@ def _build_vae(self, **kwargs): h = self.encoder(x) z_mean = tf.keras.layers.Dense(self.latent_dim)(h) z_log_sigma = tf.keras.layers.Dense(self.latent_dim)(h) - KLDivergenceLayer()([z_log_sigma, z_mean]) # kl loss + KLDivergenceLayer()([z_log_sigma, z_mean]) # kl loss z = tf.keras.layers.Lambda(self._sampling)([z_mean, z_log_sigma]) y_ = self.generator(z) From 0bcdb35b3128b8505570081e161d4390ac482131 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 22 Mar 2025 01:09:39 -0400 Subject: [PATCH 15/18] timesfm only supported on python 3.11 --- .github/workflows/tests.yml | 4 ++-- setup.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9e8f3a04..618e4fa3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -86,7 +86,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.11', '3.12'] + python-version: ['3.11'] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v1 @@ -148,7 +148,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.11', '3.12'] + python-version: ['3.11'] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v1 diff --git a/setup.py b/setup.py index 4136160a..3eb44918 100644 --- a/setup.py +++ b/setup.py @@ -45,8 +45,8 @@ 'smart_open', #timesfm - "timesfm[torch]>=1.2.0,<1.5;python_version>='3.11'", - "jax;python_version>='3.11'", + "timesfm[torch]>=1.2.0,<1.5;python_version>=3.11,<3.12", + "jax;python_version>=3.11,<3.12", ] From f96f21eb0cb01b40f0d983d751a0fa31f735f4c3 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 22 Mar 2025 02:03:22 -0400 Subject: [PATCH 16/18] remove tabulate --- .github/workflows/tests.yml | 2 +- orion/__main__.py | 9 --------- setup.py | 8 +++----- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 618e4fa3..cc20edee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -115,7 +115,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install package and dependencies run: | - python -m pip install --upgrade pip + python -m pip install --upgrade 'pip<=24.1' python -m pip install invoke .[test] - name: invoke minimum run: invoke minimum diff --git a/orion/__main__.py b/orion/__main__.py index fe026cbe..8bb13e4d 100644 --- a/orion/__main__.py +++ b/orion/__main__.py @@ -5,8 +5,6 @@ import logging import warnings -import tabulate - from orion.analysis import get_available_templates from orion.benchmark import benchmark from orion.evaluation import CONTEXTUAL_METRICS as METRICS @@ -27,13 +25,6 @@ def _evaluate(args): print('Writing results in {}'.format(args.output)) scores.to_csv(args.output, index=False) - print(tabulate.tabulate( - scores, - showindex=False, - tablefmt='github', - headers=scores.columns - )) - def get_parser(): diff --git a/setup.py b/setup.py index 3eb44918..da02308f 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,6 @@ install_requires = [ - 'Keras>=3,<4', 'tensorflow>=2.16.1,<2.20', 'numpy>=1.23.5,<2', 'pandas>=1.4.0,<3', @@ -26,9 +25,8 @@ 'ml-stars>=0.2.2,<0.4', 'scikit-learn>=1.1.0,<1.6', 'scipy>=1.8.0,<2', - 'tabulate>=0.8.3,<0.9', 'pyts>=0.11,<0.14', - 'torch>=1.9.0,<2.6', + 'torch>=1.12.0,<2.6', 'azure-cognitiveservices-anomalydetector>=0.3,<0.4', 'xlsxwriter>=1.3.6,<1.4', 'tqdm>=4.36.1', @@ -45,8 +43,8 @@ 'smart_open', #timesfm - "timesfm[torch]>=1.2.0,<1.5;python_version>=3.11,<3.12", - "jax;python_version>=3.11,<3.12", + "timesfm[torch]>=1.2.0,<1.5;python_version>='3.11' and python_version<'3.12'", + "jax;python_version>='3.11' and python_version<'3.12'", ] From 9f9cfdd0c5c3442e91b9a23ed0895a17f357329d Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 22 Mar 2025 15:10:43 -0400 Subject: [PATCH 17/18] change loss name --- orion/primitives/vae.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/orion/primitives/vae.py b/orion/primitives/vae.py index 0bebe7ff..eb99c4a4 100644 --- a/orion/primitives/vae.py +++ b/orion/primitives/vae.py @@ -21,7 +21,7 @@ LOGGER = logging.getLogger(__name__) -class KLDivergenceLayer(tf.keras.layers.Layer): +class KLDivergenceLoss(tf.keras.layers.Layer): def call(self, inputs): z_log_sigma, z_mean = inputs kl_loss = -0.5 * K.mean(1 + z_log_sigma - K.square(z_mean) - K.exp(z_log_sigma), axis=-1) @@ -178,7 +178,7 @@ def _build_vae(self, **kwargs): h = self.encoder(x) z_mean = tf.keras.layers.Dense(self.latent_dim)(h) z_log_sigma = tf.keras.layers.Dense(self.latent_dim)(h) - KLDivergenceLayer()([z_log_sigma, z_mean]) # kl loss + KLDivergenceLoss()([z_log_sigma, z_mean]) # kl loss z = tf.keras.layers.Lambda(self._sampling)([z_mean, z_log_sigma]) y_ = self.generator(z) @@ -213,7 +213,7 @@ def fit(self, X: np.ndarray, y: np.ndarray, **kwargs): batch_size=self.batch_size, epochs=self.epochs, shuffle=self.shuffle, - verbose=True, + verbose=self.verbose, callbacks=callbacks, validation_split=self.validation_split, ) From fa3ca1868214699b63fd74b2e26cee1e284dbc98 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Sat, 22 Mar 2025 15:27:01 -0400 Subject: [PATCH 18/18] remove comments --- setup.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/setup.py b/setup.py index da02308f..50d0ad45 100644 --- a/setup.py +++ b/setup.py @@ -67,7 +67,6 @@ # docs 'docutils>=0.12,<1', - # 'm2r2>=0.2.5,<0.3', 'nbsphinx>=0.5.0,<1', 'sphinx_toolbox>=2.5,<4', 'Sphinx>=3,<8', @@ -76,16 +75,7 @@ 'ipython>=6.5,<12', 'Jinja2>=2,<4', 'pickleshare', # ipython sphinx - - # fails on Sphinx < v3.4 - # 'alabaster<=0.7.12', - # fails on Sphins < v5.0 - # 'sphinxcontrib-applehelp<1.0.8', - # 'sphinxcontrib-devhelp<1.0.6', - # 'sphinxcontrib-htmlhelp<2.0.5', - # 'sphinxcontrib-serializinghtml<1.1.10', - # 'sphinxcontrib-qthelp<1.0.7', - + # style check 'flake8>=3.7.7,<4', 'isort>=4.3.4,<5',