From e709e0a3248dec4270aac286242fb4818b37d788 Mon Sep 17 00:00:00 2001 From: Sarah Alnegheimish Date: Thu, 14 Mar 2024 15:34:44 -0400 Subject: [PATCH] update python, tests, and docs --- .github/workflows/tests.yml | 18 ++++++++---- mlprimitives/adapters/statsmodels.py | 6 ++-- .../custom/timeseries_preprocessing.py | 6 +++- .../primitives/xgboost.XGBClassifier.json | 1 - .../primitives/xgboost.XGBRegressor.json | 1 - setup.py | 28 +++++++++++++------ tests/adapters/test_statsmodels.py | 8 +++--- tests/custom/test_timeseries_preprocessing.py | 2 +- tox.ini | 12 ++++---- 9 files changed, 51 insertions(+), 31 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 54218446..aa9757ae 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.6, 3.7, 3.8] + python-version: ['3.8', '3.9', '3.10', '3.11'] os: [ubuntu-20.04, macos-latest] steps: - uses: actions/checkout@v1 @@ -20,7 +20,9 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install package - run: pip install .[dev] + run: | + pip install --upgrade pip setuptools wheel + pip install .[dev] - name: make test-devel run: make test-devel @@ -28,7 +30,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.6, 3.7, 3.8] + python-version: ['3.8', '3.9', '3.10', '3.11'] os: [ubuntu-20.04, macos-latest] steps: - uses: actions/checkout@v1 @@ -37,7 +39,9 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install package and dependencies - run: pip install rundoc . + run: | + pip install --upgrade pip setuptools wheel + pip install rundoc . - name: make test-readme run: make test-readme @@ -45,7 +49,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.6, 3.7, 3.8] + python-version: ['3.8', '3.9', '3.10', '3.11'] os: [ubuntu-20.04, macos-latest] steps: - uses: actions/checkout@v1 @@ -54,6 +58,8 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install package and dependencies - run: pip install .[test] + run: | + pip install --upgrade pip setuptools wheel + pip install .[test] - name: make test-unit run: make test-unit diff --git a/mlprimitives/adapters/statsmodels.py b/mlprimitives/adapters/statsmodels.py index 78a70e8d..fa9cf237 100644 --- a/mlprimitives/adapters/statsmodels.py +++ b/mlprimitives/adapters/statsmodels.py @@ -1,5 +1,5 @@ import numpy as np -from statsmodels.tsa import arima_model +from statsmodels.tsa.arima import model class ARIMA(object): @@ -45,8 +45,8 @@ def predict(self, X): num_sequences = len(X) for sequence in range(num_sequences): - arima = arima_model.ARIMA(X[sequence], order=(self.p, self.d, self.q)) - arima_fit = arima.fit(disp=0) + arima = model.ARIMA(X[sequence], order=(self.p, self.d, self.q)) + arima_fit = arima.fit() arima_results.append(arima_fit.forecast(self.steps)[0]) arima_results = np.asarray(arima_results) diff --git a/mlprimitives/custom/timeseries_preprocessing.py b/mlprimitives/custom/timeseries_preprocessing.py index 56484400..db1093ba 100644 --- a/mlprimitives/custom/timeseries_preprocessing.py +++ b/mlprimitives/custom/timeseries_preprocessing.py @@ -269,4 +269,8 @@ def cutoff_window_sequences(X, timeseries, window_size, cutoff_time=None, time_i output.append(selected.values) - return np.array(output) + output = np.array(output, dtype=object) + if output.ndim >= 2: + output = output.astype(float) + + return output diff --git a/mlprimitives/primitives/xgboost.XGBClassifier.json b/mlprimitives/primitives/xgboost.XGBClassifier.json index d2d73931..e55c0203 100644 --- a/mlprimitives/primitives/xgboost.XGBClassifier.json +++ b/mlprimitives/primitives/xgboost.XGBClassifier.json @@ -29,7 +29,6 @@ "args": [ { "name": "X", - "keyword": "data", "type": "ndarray" } ], diff --git a/mlprimitives/primitives/xgboost.XGBRegressor.json b/mlprimitives/primitives/xgboost.XGBRegressor.json index 6503adbe..43c78c8f 100644 --- a/mlprimitives/primitives/xgboost.XGBRegressor.json +++ b/mlprimitives/primitives/xgboost.XGBRegressor.json @@ -29,7 +29,6 @@ "args": [ { "name": "X", - "keyword": "data", "type": "ndarray" } ], diff --git a/setup.py b/setup.py index 63216e19..4b20e282 100644 --- a/setup.py +++ b/setup.py @@ -12,24 +12,24 @@ history = history_file.read() install_requires = [ - 'Keras>=2.4,<2.5', + 'Keras>=2.4,<2.15', 'featuretools>=0.6.1,<0.23', 'iso639>=0.1.4,<0.2', 'langdetect>=1.0.7,<2', 'lightfm>=1.15,<2', - 'mlblocks>=0.4.0.dev0,<0.7', + 'mlblocks>=0.6,<0.7', 'networkx>=2.0,<3', 'nltk>=3.3,<4', - 'numpy<1.21.0,>=1.16.0', + 'numpy>=1.16.0,<2', 'opencv-python>=3.4.0.12,<4.7', 'pandas>=1,<2', 'python-louvain>=0.10,<0.14', # community 'scikit-image>=0.15', 'scikit-learn>=0.21', 'scipy>=1.1.0,<2', - 'statsmodels>=0.9.0,<0.13', - 'tensorflow>=2,<2.5', - 'xgboost>=0.72.1,<1', + 'statsmodels>=0.9.0,<0.15', + 'tensorflow>=2,<2.15', + 'xgboost>=0.72.1,<2', 'protobuf<4', ] @@ -59,6 +59,15 @@ 'mistune>=0.7,<2', 'Jinja2>=2,<3.1', + # 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', @@ -91,9 +100,10 @@ 'License :: OSI Approved :: MIT License', '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='Pipelines and primitives for machine learning and data science.', entry_points = { @@ -117,7 +127,7 @@ long_description_content_type='text/markdown', name='mlprimitives', packages=find_packages(include=['mlprimitives', 'mlprimitives.*']), - python_requires='>=3.6,<3.9', + python_requires='>=3.8,<3.12', setup_requires=setup_requires, test_suite='tests', tests_require=tests_require, diff --git a/tests/adapters/test_statsmodels.py b/tests/adapters/test_statsmodels.py index bca5ec1f..88f7b348 100644 --- a/tests/adapters/test_statsmodels.py +++ b/tests/adapters/test_statsmodels.py @@ -6,7 +6,7 @@ from mlprimitives.adapters.statsmodels import ARIMA -@patch('statsmodels.tsa.arima_model.ARIMA') +@patch('statsmodels.tsa.arima.model.ARIMA') def test_arima_1d(arima_mock): arima = ARIMA(1, 0, 0, 3) X = np.array([1, 2, 3, 4, 5]) @@ -15,7 +15,7 @@ def test_arima_1d(arima_mock): assert arima_mock.call_args[1] == {'order': (1, 0, 0)} -@patch('statsmodels.tsa.arima_model.ARMAResults.forecast') +@patch('statsmodels.tsa.arima.model.ARIMAResultsWrapper.forecast') def test_predict_1d(arima_mock): arima_mock.return_value = [[1, 2, 3]] @@ -29,7 +29,7 @@ def test_predict_1d(arima_mock): arima_mock.assert_called_once_with(3) -@patch('statsmodels.tsa.arima_model.ARIMA') +@patch('statsmodels.tsa.arima.model.ARIMA') def test_arima_2d(arima_mock): arima = ARIMA(1, 0, 0, 3) X = np.array([ @@ -46,7 +46,7 @@ def test_arima_2d(arima_mock): assert arima_mock.call_args_list[2][1] == {'order': (1, 0, 0)} -@patch('statsmodels.tsa.arima_model.ARMAResults.forecast') +@patch('statsmodels.tsa.arima.model.ARIMAResultsWrapper.forecast') def test_predict_2d(arima_mock): arima_mock.side_effect = [ [[1, 2, 3]], diff --git a/tests/custom/test_timeseries_preprocessing.py b/tests/custom/test_timeseries_preprocessing.py index 05b4b264..aed89662 100644 --- a/tests/custom/test_timeseries_preprocessing.py +++ b/tests/custom/test_timeseries_preprocessing.py @@ -417,7 +417,7 @@ def test_not_enough_data(self): [15, 35], [16, 36] ]) - ]) + ], dtype=object) assert_allclose( array[0], diff --git a/tox.ini b/tox.ini index a63bfd39..9a25c4d2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,19 @@ [tox] -envlist = py3{6,7,8}, test-devel +envlist = py3{8,9,10,11}, test-devel [travis] python = 3.8: py38, test-devel - 3.7: py37 - 3.6: py36 + 3.9: py39 + 3.10: py310 + 3.11: py311 [gh-actions] python = 3.8: py38, test-devel - 3.7: py37 - 3.6: py36 + 3.9: py39 + 3.10: py310 + 3.11: py311 [testenv] passenv = CI TRAVIS TRAVIS_*