Skip to content

Commit

Permalink
make release-tag: Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahmish committed Oct 24, 2023
2 parents 0e72c40 + bc6d5c9 commit 6ffb4a8
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 128 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,8 +32,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
os: [ubuntu-20.04]
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -50,8 +50,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
os: [ubuntu-20.04, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -68,8 +68,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
os: [ubuntu-20.04, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
Expand Down
9 changes: 9 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# History

## 0.2.0 – 2023-10-24

* Upgrade python tests & remove python 3.7 [Issue #11](https://github.com/sintel-dev/ml-stars/issues/11) - by @sarahmish
* Add deprecation warning for old ARIMA primitive [Issue #10](https://github.com/sintel-dev/ml-stars/issues/10) - by @sarahmish
* Remove python 3.6 [Issue #9](https://github.com/sintel-dev/ml-stars/issues/9) - by @sarahmish
* Add support for python 3.10 & 3.11 [Issue #8](https://github.com/sintel-dev/ml-stars/issues/8) - by @sarahmish


## 0.1.3 – 2023-09-25

* Update ``keras`` adapter [Issue #7](https://github.com/sintel-dev/ml-stars/issues/7) - by @sarahmish


## 0.1.2 – 2023-08-04

* Add python 3.9 [Issue #6](https://github.com/sintel-dev/ml-stars/issues/6) - by @sarahmish
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ combine third party tools or implement new functionalities from scratch.

## Requirements

**ml-stars** has been developed and tested on [Python 3.6, 3.7, 3.8, and 3.9](https://www.python.org/downloads/)
**ml-stars** has been developed and tested on [Python 3.8, 3.9, 3.10, and 3.11](https://www.python.org/downloads/)

Also, although it is not strictly required, the usage of a
[virtualenv](https://virtualenv.pypa.io/en/latest/) is highly recommended in order to avoid
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Requirements

Python
~~~~~~
**ml-stars** has been tested on **GNU/Linux**, and **macOS** systems running `Python 3.6, 3.7, or 3.8`_ installed.
**ml-stars** has been tested on **GNU/Linux**, and **macOS** systems running `Python 3.8, 3.9, 3.10, or 3.11`_ installed.

Also, although it is not strictly required, the usage of a `virtualenv`_ is highly recommended in
order to avoid having conflicts with other software installed in the system where you are trying to run **ml-stars**.
Expand Down Expand Up @@ -45,7 +45,7 @@ from its sources, in the editable mode, and also including some additional depen
order to be able to run the tests and build the documentation. Instructions about this process
can be found in the :ref:`contributing` guide.

.. _Python 3.6, 3.7, or 3.8: https://docs.python-guide.org/starting/installation/
.. _Python 3.8, 3.9, 3.10, or 3.11: https://docs.python-guide.org/starting/installation/
.. _virtualenv: https://virtualenv.pypa.io/en/latest/
.. _pip: https://pip.pypa.io
.. _PyPI: https://pypi.org/
Expand Down
2 changes: 1 addition & 1 deletion mlstars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = 'MIT Data To AI Lab'
__email__ = '[email protected]'
__version__ = '0.1.3'
__version__ = '0.2.0.dev0'

import os

Expand Down
25 changes: 20 additions & 5 deletions mlstars/adapters/statsmodels.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import warnings

import numpy as np
from statsmodels.tsa import arima_model
from statsmodels.tsa.arima import model

_ARIMA_MODEL_DEPRECATION_WARNING = (
"statsmodels.tsa.arima_model.Arima is deprecated "
"and will be removed in a future version. Please use "
"statsmodels.tsa.arima.model.ARIMA instead."
)


class ARIMA(object):
"""A Wrapper for the statsmodels.tsa.arima_model.ARIMA class."""
"""A Wrapper for the statsmodels.tsa.arima.model.ARIMA class."""

def __init__(self, p, d, q, steps):
def __init__(self, p, d, q, trend, steps):
"""Initialize the ARIMA object.
Args:
Expand All @@ -15,12 +23,19 @@ def __init__(self, p, d, q, steps):
Integer denoting the degree of differencing.
q (int):
Integer denoting the order of the moving-average model.
trend (str):
Parameter controlling the deterministic trend. Can be specified
as a string where 'c' indicates a constant term, 't' indicates
a linear trend in time, and 'ct' includes both.
steps (int):
Integer denoting the number of time steps to predict ahead.
"""
warnings.warn(_ARIMA_MODEL_DEPRECATION_WARNING, DeprecationWarning)

self.p = p
self.d = d
self.q = q
self.trend = trend
self.steps = steps

def predict(self, X):
Expand All @@ -45,8 +60,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), trend=self.trend)
arima_fit = arima.fit()
arima_results.append(arima_fit.forecast(self.steps)[0])

arima_results = np.asarray(arima_results)
Expand Down
53 changes: 5 additions & 48 deletions mlstars/custom/timeseries_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,53 +111,6 @@ def rolling_window_sequences(X, index, window_size, target_size, step_size, targ
return np.asarray(out_X), np.asarray(out_y), np.asarray(X_index), np.asarray(y_index)


_TIME_SEGMENTS_AVERAGE_DEPRECATION_WARNING = (
"mlstars.custom.timeseries_preprocessing.time_segments_average "
"is deprecated and will be removed in a future version. Please use "
"mlstars.custom.timeseries_preprocessing.time_segments_aggregate instead."
)


def time_segments_average(X, interval, time_column):
"""Compute average of values over given time span.
Args:
X (ndarray or pandas.DataFrame):
N-dimensional sequence of values.
interval (int):
Integer denoting time span to compute average of.
time_column (int):
Column of X that contains time values.
Returns:
ndarray, ndarray:
* Sequence of averaged values.
* Sequence of index values (first index of each averaged segment).
"""
warnings.warn(_TIME_SEGMENTS_AVERAGE_DEPRECATION_WARNING, DeprecationWarning)

if isinstance(X, np.ndarray):
X = pd.DataFrame(X)

X = X.sort_values(time_column).set_index(time_column)

start_ts = X.index.values[0]
max_ts = X.index.values[-1]

values = list()
index = list()

while start_ts <= max_ts:
end_ts = start_ts + interval
subset = X.loc[start_ts:end_ts - 1]
means = subset.mean(skipna=True).values
values.append(means)
index.append(start_ts)
start_ts = end_ts

return np.asarray(values), np.asarray(index)


def time_segments_aggregate(X, interval, time_column, method=['mean']):
"""Aggregate values over given time span.
Expand Down Expand Up @@ -269,4 +222,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
67 changes: 67 additions & 0 deletions mlstars/primitives/statsmodels.tsa.arima.model.ARIMA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "statsmodels.tsa.arima.model.ARIMA",
"contributors": [
"Alexander Geiger <[email protected]>",
"Sarah Alnegheimish <[email protected]>"
],
"description": "ARIMA Model",
"classifiers": {
"type": "estimator",
"subtype": "regressor"
},
"modalities": [],
"primitive": "mlstars.adapters.statsmodels.ARIMA",
"produce": {
"method": "predict",
"args": [
{
"name": "X",
"type": "ndarray"
}
],
"output": [
{
"name": "y",
"type": "ndarray"
}
]
},
"hyperparameters": {
"fixed": {
"trend": {
"type": "str",
"default": "t"
},
"steps": {
"type": "int",
"default": 10
}
},
"tunable": {
"p": {
"type": "int",
"default": 1,
"range": [
0,
40
]
},
"d": {
"type": "int",
"default": 0,
"range": [
0,
3
]
},
"q": {
"type": "int",
"default": 0,
"range": [
0,
12
]
}
}
}
}
6 changes: 5 additions & 1 deletion mlstars/primitives/statsmodels.tsa.arima_model.Arima.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"contributors": [
"Alexander Geiger <[email protected]>"
],
"description": "ARIMA Model",
"description": "ARIMA Model; mstatsmodels.tsa.arima_model.Arima is deprecated and will be removed in a future version. Please use statsmodels.tsa.arima.model.ARIMA instead.",
"classifiers": {
"type": "estimator",
"subtype": "regressor"
Expand All @@ -27,6 +27,10 @@
},
"hyperparameters": {
"fixed": {
"trend": {
"type": "str",
"default": "t"
},
"steps": {
"type": "int",
"default": 10
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.3
current_version = 0.2.0.dev0
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<candidate>\d+))?
Expand Down
31 changes: 15 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
history = history_file.read()

install_requires = [
'Keras>=2.4,<2.13',
'mlblocks>=0.6',
'numpy<1.21.0,>=1.16.0',
'pandas>=1,<2',
'scikit-learn>=0.21,<1.2',
'scipy>=1.1.0,<2',
'statsmodels>=0.9.0,<0.13',
'tensorflow>=2,<2.13',
'xgboost>=0.72.1,<1',
'Keras>=2.4,<2.15',
'mlblocks>=0.6.1',
'numpy>=1.17.4,<2',
'pandas>=1,<3',
'scikit-learn>=0.22,<1.2',
'scipy>=1.4.1,<2',
'statsmodels>=0.12.0,<0.15',
'tensorflow>=2.2,<2.15',
'xgboost>=0.72.1,<2',

# fix google/protobuf/descriptor
'protobuf<4',
Expand Down Expand Up @@ -46,10 +46,8 @@
'nbsphinx>=0.5.0,<0.7',
'Sphinx>=3,<3.3',
'pydata-sphinx-theme<0.5',
'autodocsumm>=0.1.10,<1',
'markupsafe<2.1.0',
'ipython>=6.5,<7.5',
'mistune>=0.7,<2',
'ipython>=6.5,<9',
'Jinja2>=2,<3',

# style check
Expand All @@ -68,6 +66,7 @@
# Advanced testing
'coverage>=4.5.1',
'tox>=2.9.1',
'invoke',
]

setup(
Expand All @@ -79,10 +78,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='Primitives and Pipelines for Time Series Data.',
entry_points={
Expand All @@ -104,11 +103,11 @@
keywords='mlstars',
name='ml-stars',
packages=find_packages(include=['mlstars', 'mlstars.*']),
python_requires='>=3.6,<3.10',
python_requires='>=3.8,<3.12',
setup_requires=setup_requires,
test_suite='tests',
tests_require=tests_require,
url='https://github.com/sintel-dev/ml-stars',
version='0.1.3',
version='0.2.0.dev0',
zip_safe=False,
)
2 changes: 1 addition & 1 deletion tests/adapters/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np
import pandas as pd
from pandas.util.testing import assert_frame_equal
from pandas.testing import assert_frame_equal

from mlstars.adapters.pandas import resample

Expand Down
Loading

0 comments on commit 6ffb4a8

Please sign in to comment.