From 3e3f8ac3ae3d1097d8edb635054f220d7b70a30a Mon Sep 17 00:00:00 2001 From: Sara Pido Date: Tue, 5 Mar 2024 20:26:38 +0000 Subject: [PATCH 1/3] labeling function for planet bearing --- .../labeling_functions/planet_bearing.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 zephyr_ml/labeling/labeling_functions/planet_bearing.py diff --git a/zephyr_ml/labeling/labeling_functions/planet_bearing.py b/zephyr_ml/labeling/labeling_functions/planet_bearing.py new file mode 100644 index 0000000..973dd0d --- /dev/null +++ b/zephyr_ml/labeling/labeling_functions/planet_bearing.py @@ -0,0 +1,47 @@ +from zephyr_ml.labeling.utils import denormalize + +def gearbox_replace_presence(es, column_map={}): + """Determines if gearbox replacement/exchange is present in stoppages. + + Args: + es (ft.EntitySet): + EntitySet of data to check gearbox replacements. + column_map (dict): + Optional dictionary to update default column names to the + actual corresponding column names in the data slice. Can contain the + following keys: + "comments": Column that contains comments about the stoppage. Defaults + to "DES_COMMENTS". + "turbine_id": Column containing the ID of the turbine associated with a + stoppage. Must match the index column of the 'turbines' entity. + Defaults to "COD_ELEMENT". + "time_index": Column to use as the time index for the data slice. + Defaults to "DAT_END". + + Returns: + label: + Labeling function to find gearbox replacement presence over a data slice. + df: + Denormalized dataframe of data to get labels from. + meta: + Dictionary containing metadata about labeling function. + + """ + comments = column_map.get('comments_column', 'DES_COMMENTS') + turbine_id = column_map.get('turbine_id_column', 'COD_ELEMENT') + time_index = column_map.get('time_index_column', 'DAT_END') + + def label(ds, **kwargs): + label_strings = ['Gearbox replace*', 'Gearbox exchange'] + comments_lower = ds[comments].fillna('').str.lower() + f = any(comments_lower.str.contains('|'.join(label_strings), case=False)) + return f + + meta = { + "target_entity_index": turbine_id, + "time_index": time_index, + } + + df = denormalize(es, entities=['stoppages']) + + return label, df, meta From 642545f31dac365c79d4ee8345d7bd01fe2bd582 Mon Sep 17 00:00:00 2001 From: Sara Pido Date: Wed, 6 Mar 2024 22:21:55 +0000 Subject: [PATCH 2/3] update dependencies --- .github/workflows/tests.yml | 6 +++--- setup.py | 13 +++++++------ tests/test_core.py | 2 +- tox.ini | 15 ++++++++++----- .../labeling/labeling_functions/planet_bearing.py | 1 + 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 66e4715..f031f2b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.7, 3.8] + python-version: ["3.8", "3.9", "3.10", "3.11"] os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v1 @@ -45,7 +45,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.7, 3.8] + python-version: ["3.8", "3.9", "3.10", "3.11"] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v1 @@ -62,7 +62,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.7, 3.8] + python-version: ["3.8", "3.9", "3.10", "3.11"] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v1 diff --git a/setup.py b/setup.py index f1996bc..0378b97 100644 --- a/setup.py +++ b/setup.py @@ -18,12 +18,12 @@ history = '' install_requires = [ - 'numpy>=1.16.0,<1.23.0', + 'numpy>=1.19.5,<1.27.0', 'pandas>=1,<2', 'composeml>=0.1.6,<0.10', 'featuretools>=1.0.0,<2.0.0', - 'mlblocks>=0.5.0,<0.6', - 'sigpro>=0.1.1.dev0', + 'mlblocks>=0.6.0,<0.7', + 'sigpro>=0.2.0', 'xgboost>=0.72.1,<1', 'jupyter==1.0.0', ] @@ -83,9 +83,10 @@ 'Intended Audience :: Developers', 'Natural Language :: English', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ], description='Prediction engineering methods for Draco.', entry_points={ @@ -106,7 +107,7 @@ keywords='zephyr Draco Prediction Engineering', name='zephyr-ml', packages=find_packages(include=['zephyr_ml', 'zephyr_ml.*']), - python_requires='>=3.7,<3.9', + python_requires='>=3.8,<3.12', setup_requires=setup_requires, test_suite='tests', tests_require=tests_require, diff --git a/tests/test_core.py b/tests/test_core.py index 244617f..cc747c7 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -31,7 +31,7 @@ def setup_class(cls): }) cls.random_y = [1 if x > 0.5 else 0 for x in np.random.random(100)] - def setup(self): + def setup_method(self): self.zephyr = Zephyr('xgb_classifier') def test_hyperparameters(self): diff --git a/tox.ini b/tox.ini index 8fcdc38..e427b6b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,15 +1,19 @@ [tox] -envlist = py3{7,8}, test-devel +envlist = py3{8,9,10,11}-{lint,readme,pytest,tutorials}, test-devel [travis] python = - 3.8: py38, test-devel - 3.7: py37 + 3.11: py311-lint, py311-readme, py311-pytest, py311-tutorials + 3.10: py310-lint, py310-readme, py310-pytest, py310-tutorials + 3.9: py39-lint, py39-readme, py39-pytest, py39-tutorials + 3.8: py38-lint, py38-readme, py38-pytest, py38-tutorials [gh-actions] python = - 3.7: py37, test-devel - 3.8: py38 + 3.11: py311-lint, py311-readme, py311-pytest, py311-tutorials + 3.10: py310-lint, py310-readme, py310-pytest, py310-tutorials + 3.9: py39-lint, py39-readme, py39-pytest, py39-tutorials + 3.8: py38-lint, py38-readme, py38-pytest, py38-tutorials [testenv] passenv = CI TRAVIS TRAVIS_* @@ -23,3 +27,4 @@ commands = extras = dev commands = /usr/bin/env make test-devel + \ No newline at end of file diff --git a/zephyr_ml/labeling/labeling_functions/planet_bearing.py b/zephyr_ml/labeling/labeling_functions/planet_bearing.py index 973dd0d..283e5cd 100644 --- a/zephyr_ml/labeling/labeling_functions/planet_bearing.py +++ b/zephyr_ml/labeling/labeling_functions/planet_bearing.py @@ -1,5 +1,6 @@ from zephyr_ml.labeling.utils import denormalize + def gearbox_replace_presence(es, column_map={}): """Determines if gearbox replacement/exchange is present in stoppages. From a27ea32a6838c172aa681c24f94645206895a2bc Mon Sep 17 00:00:00 2001 From: Sara Pido Date: Wed, 6 Mar 2024 22:32:49 +0000 Subject: [PATCH 3/3] remove planet bearing lf --- .../labeling_functions/planet_bearing.py | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 zephyr_ml/labeling/labeling_functions/planet_bearing.py diff --git a/zephyr_ml/labeling/labeling_functions/planet_bearing.py b/zephyr_ml/labeling/labeling_functions/planet_bearing.py deleted file mode 100644 index 283e5cd..0000000 --- a/zephyr_ml/labeling/labeling_functions/planet_bearing.py +++ /dev/null @@ -1,48 +0,0 @@ -from zephyr_ml.labeling.utils import denormalize - - -def gearbox_replace_presence(es, column_map={}): - """Determines if gearbox replacement/exchange is present in stoppages. - - Args: - es (ft.EntitySet): - EntitySet of data to check gearbox replacements. - column_map (dict): - Optional dictionary to update default column names to the - actual corresponding column names in the data slice. Can contain the - following keys: - "comments": Column that contains comments about the stoppage. Defaults - to "DES_COMMENTS". - "turbine_id": Column containing the ID of the turbine associated with a - stoppage. Must match the index column of the 'turbines' entity. - Defaults to "COD_ELEMENT". - "time_index": Column to use as the time index for the data slice. - Defaults to "DAT_END". - - Returns: - label: - Labeling function to find gearbox replacement presence over a data slice. - df: - Denormalized dataframe of data to get labels from. - meta: - Dictionary containing metadata about labeling function. - - """ - comments = column_map.get('comments_column', 'DES_COMMENTS') - turbine_id = column_map.get('turbine_id_column', 'COD_ELEMENT') - time_index = column_map.get('time_index_column', 'DAT_END') - - def label(ds, **kwargs): - label_strings = ['Gearbox replace*', 'Gearbox exchange'] - comments_lower = ds[comments].fillna('').str.lower() - f = any(comments_lower.str.contains('|'.join(label_strings), case=False)) - return f - - meta = { - "target_entity_index": turbine_id, - "time_index": time_index, - } - - df = denormalize(es, entities=['stoppages']) - - return label, df, meta