diff --git a/requirements_stable.txt b/requirements_stable.txt index de32f25..0e0cf3a 100644 --- a/requirements_stable.txt +++ b/requirements_stable.txt @@ -1,46 +1,51 @@ -atomicwrites==1.3.0 -attrs==19.1.0 +appnope==0.1.0 +backcall==0.1.0 bleach==3.1.0 -certifi==2019.6.16 -cffi==1.12.3 +certifi==2019.11.28 chardet==3.0.4 Click==7.0 -Cython==0.29.13 +Cython==0.29.14 +decorator==4.4.1 docutils==0.15.2 idna==2.8 -importlib-metadata==0.19 -Jinja2==2.10.1 -joblib==0.13.2 -MarkupSafe==1.1.1 -more-itertools==7.2.0 -numpy==1.17.0 -packaging==19.1 -pandas==0.25.0 +importlib-metadata==1.3.0 +ipykernel==5.1.3 +ipython==7.9.0 +ipython-genutils==0.2.0 +jedi==0.15.1 +joblib==0.14.1 +jupyter-client==5.3.4 +jupyter-core==4.6.1 +keyring==21.0.0 +more-itertools==8.0.2 +numpy==1.18.1 +pandas==0.25.3 +parso==0.5.1 patsy==0.5.1 -pip-tools==4.0.0 +pexpect==4.7.0 +pickleshare==0.7.5 +pip-tools==4.3.0 pkginfo==1.5.0.1 -pluggy==0.12.0 -pmdarima==1.2.1 -py==1.8.0 -pycparser==2.19 +pmdarima==1.5.2 +prompt-toolkit==2.0.10 +ptyprocess==0.6.0 Pygments==2.4.2 -pyparsing==2.4.2 -pytest==5.0.1 -python-dateutil==2.8.0 -pytz==2019.2 +python-dateutil==2.8.1 +pytz==2019.3 +pyzmq==18.1.0 readme-renderer==24.0 requests==2.22.0 requests-toolbelt==0.9.1 -rpy2==3.0.5 -scikit-learn==0.21.3 -scipy==1.3.0 -simplegeneric==0.8.1 +scikit-learn==0.22.1 +scipy==1.4.1 six==1.12.0 -statsmodels==0.10.1 --e git+git@github.com:intive-DataScience/tbats.git@4e726919f08e39e74dd70a592b5258dfc7b25953#egg=tbats -tqdm==4.32.2 -twine==1.13.0 -urllib3==1.25.3 +statsmodels==0.10.2 +-e git+git@github.com:intive-DataScience/tbats.git@75bc957e425c3b82dfe75373e2cea7aff17ecc12#egg=tbats +tornado==6.0.3 +tqdm==4.41.1 +traitlets==4.3.3 +twine==3.1.1 +urllib3==1.25.7 wcwidth==0.1.7 webencodings==0.5.1 -zipp==0.5.2 +zipp==0.6.0 diff --git a/setup.py b/setup.py index 290a5c7..63f1f0d 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ def run_tests(self): setuptools.setup( name='tbats', - version='1.0.8', + version='1.0.9', packages=setuptools.find_packages(exclude=('test', 'test_R')), url='https://github.com/intive-DataScience/tbats', license='MIT License', diff --git a/tbats/abstract/Estimator.py b/tbats/abstract/Estimator.py index 13b0742..bcc4b6e 100644 --- a/tbats/abstract/Estimator.py +++ b/tbats/abstract/Estimator.py @@ -1,5 +1,6 @@ import numpy as np -import multiprocessing +import multiprocessing as actual_processing +import multiprocessing.dummy as dummy_processing from sklearn.base import BaseEstimator from sklearn.utils.validation import check_array, column_or_1d as c1d from sklearn.model_selection import ParameterGrid @@ -139,7 +140,7 @@ def _choose_model_from_possible_component_settings(self, y, components_grid): """ self._y = y # note n_jobs = None means to use cpu_count() - pool = multiprocessing.pool.Pool(processes=self.n_jobs) + pool = self._prepare_pool(self.n_jobs) models = pool.map(self._case_fit, components_grid) pool.close() self._y = None # clean-up @@ -151,6 +152,11 @@ def _choose_model_from_possible_component_settings(self, y, components_grid): best_model = model return best_model + def _prepare_pool(self, n_jobs=None): + if n_jobs == 1: + return dummy_processing.Pool(processes=n_jobs) + return actual_processing.Pool(processes=n_jobs) + def _prepare_components_grid(self, seasonal_harmonics=None): """Provides a grid of all allowed model component combinations. diff --git a/tbats/tbats/HarmonicsChoosingStrategy.py b/tbats/tbats/HarmonicsChoosingStrategy.py index d7422cc..0c1f71a 100644 --- a/tbats/tbats/HarmonicsChoosingStrategy.py +++ b/tbats/tbats/HarmonicsChoosingStrategy.py @@ -1,6 +1,7 @@ import numpy as np import fractions -import multiprocessing +import multiprocessing as actual_processing +import multiprocessing.dummy as dummy_processing class HarmonicsChoosingStrategy(object): @@ -8,7 +9,7 @@ class HarmonicsChoosingStrategy(object): def __init__(self, context, n_jobs=None): self.n_jobs = n_jobs if n_jobs is None: - self.n_jobs = multiprocessing.cpu_count() + self.n_jobs = actual_processing.cpu_count() self.context = context def choose(self, y, components): @@ -78,7 +79,7 @@ def choose_for_season(self, season_index, max_harmonic, best_model_so_far): self._season_index = season_index self._y = best_model_so_far.y self._components = best_model_so_far.params.components - pool = multiprocessing.pool.Pool(processes=self.n_jobs) + pool = self._prepare_pool(self.n_jobs) models = pool.map(self._fit_model, harmonics_range) pool.close() for model in models: @@ -102,6 +103,11 @@ def choose_for_season(self, season_index, max_harmonic, best_model_so_far): return best_model_so_far return best_model + def _prepare_pool(self, n_jobs=None): + if n_jobs == 1: + return dummy_processing.Pool(processes=n_jobs) + return actual_processing.Pool(processes=n_jobs) + def _fit_model(self, harmonic_to_check): components = self._components.with_harmonic_for_season( season_index=self._season_index, new_harmonic=harmonic_to_check