From 968a3bb8ac3b903d5a839d2bcad83db70eda627f Mon Sep 17 00:00:00 2001 From: PanyiDong Date: Fri, 24 Nov 2023 23:13:08 -0600 Subject: [PATCH] update time constraints --- InsurAutoML/constant.py | 10 ++++++++- InsurAutoML/hpo/base.py | 2 +- InsurAutoML/hpo/utils.py | 14 +++++++----- InsurAutoML/model/lightgbm.py | 7 ++++-- InsurAutoML/utils/optimize.py | 2 +- requirements.txt | 41 ++++++++++++++++++----------------- requirements_nn.txt | 29 +++++++++++++------------ setup.py | 3 ++- 8 files changed, 63 insertions(+), 45 deletions(-) diff --git a/InsurAutoML/constant.py b/InsurAutoML/constant.py index cf24e3a..c167483 100644 --- a/InsurAutoML/constant.py +++ b/InsurAutoML/constant.py @@ -11,7 +11,7 @@ Author: Panyi Dong (panyid2@illinois.edu) ----- -Last Modified: Monday, 5th June 2023 10:34:19 pm +Last Modified: Friday, 24th November 2023 12:37:26 am Modified By: Panyi Dong (panyid2@illinois.edu) ----- @@ -45,6 +45,14 @@ class TimeoutException(Exception): pass +class TimeoutWarning(Warning): + def __init__(self, message): + self.message = message + + def __str__(self): + return repr(self.message) + + MAX_ERROR_TRIALOUT = 8 LOGGINGLEVEL = [logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG] diff --git a/InsurAutoML/hpo/base.py b/InsurAutoML/hpo/base.py index 8e8b374..c1479c8 100644 --- a/InsurAutoML/hpo/base.py +++ b/InsurAutoML/hpo/base.py @@ -11,7 +11,7 @@ Author: Panyi Dong (panyid2@illinois.edu) ----- -Last Modified: Thursday, 20th July 2023 5:45:39 pm +Last Modified: Friday, 24th November 2023 2:45:29 pm Modified By: Panyi Dong (panyid2@illinois.edu) ----- diff --git a/InsurAutoML/hpo/utils.py b/InsurAutoML/hpo/utils.py index efeff20..003c8f8 100644 --- a/InsurAutoML/hpo/utils.py +++ b/InsurAutoML/hpo/utils.py @@ -11,7 +11,7 @@ Author: Panyi Dong (panyid2@illinois.edu) ----- -Last Modified: Wednesday, 22nd November 2023 3:34:53 pm +Last Modified: Friday, 24th November 2023 2:48:15 pm Modified By: Panyi Dong (panyid2@illinois.edu) ----- @@ -44,8 +44,8 @@ import os import time import scipy -import warnings import logging +import func_timeout from sklearn.exceptions import ConvergenceWarning from sklearn.utils._testing import ignore_warnings from sklearn.model_selection import KFold @@ -553,9 +553,13 @@ def setup( def step(self) -> Dict[str, Any]: try: - with time_limit(self.timeout): - self.status_dict = self._objective() - except TimeoutError: + # Update: Nov. 24, 2023 + # Signal/Multiprocessing timeout methods can be ignored by ctypes callback + # Use func_timeout instead + # self.status_dict = time_limit(self.timeout)(self._objective)() + self.status_dict = func_timeout.func_timeout(self.timeout, self._objective) + # except TimeoutError: + except func_timeout.FunctionTimedOut: self._logger.warning( "Objective not finished due to timeout after {} seconds.".format( self.timeout diff --git a/InsurAutoML/model/lightgbm.py b/InsurAutoML/model/lightgbm.py index faff438..cd9a54f 100644 --- a/InsurAutoML/model/lightgbm.py +++ b/InsurAutoML/model/lightgbm.py @@ -11,7 +11,7 @@ Author: Panyi Dong (panyid2@illinois.edu) ----- -Last Modified: Thursday, 1st June 2023 9:41:03 am +Last Modified: Friday, 24th November 2023 12:21:51 am Modified By: Panyi Dong (panyid2@illinois.edu) ----- @@ -207,7 +207,10 @@ def fit( num_iterations=self.num_iterations, ) - self.model.fit(X, y) + try: + self.model.fit(X, y) + except Exception as e: + raise e self._fitted = True diff --git a/InsurAutoML/utils/optimize.py b/InsurAutoML/utils/optimize.py index a5da716..93734ec 100644 --- a/InsurAutoML/utils/optimize.py +++ b/InsurAutoML/utils/optimize.py @@ -11,7 +11,7 @@ Author: Panyi Dong (panyid2@illinois.edu) ----- -Last Modified: Wednesday, 22nd November 2023 3:34:32 pm +Last Modified: Friday, 24th November 2023 2:16:13 pm Modified By: Panyi Dong (panyid2@illinois.edu) ----- diff --git a/requirements.txt b/requirements.txt index ead0453..4c53486 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,28 +1,29 @@ -pyarrow -setuptools -pygam -ray[tune] -scikit-learn>=1.2.0 +nevergrad +lightgbm pandas -numpy<1.24.0 -matplotlib -ray<2.0.0 +flaml tensorboardX +fastparquet +func-timeout +gensim +redis optuna -cython +seaborn>=0.11.0 +matplotlib tqdm -lightgbm +colorama==0.4.4 +bayesian_optimization==1.4.0 +pyarrow +hyperopt +rpy2 +cython +ray<2.0.0 mlflow +setuptools +ray[tune] +pygam xgboost threadpoolctl>2.2.0 -hyperopt -bayesian_optimization==1.4.0 -flaml +numpy<1.24.0 +scikit-learn>=1.2.0 scipy -nevergrad -gensim -rpy2 -redis -seaborn>=0.11.0 -fastparquet -colorama==0.4.4 diff --git a/requirements_nn.txt b/requirements_nn.txt index 3201233..e8f1dd3 100644 --- a/requirements_nn.txt +++ b/requirements_nn.txt @@ -1,19 +1,20 @@ -pyarrow -setuptools -ray[tune] -torch -scikit-learn>=1.2.0 pandas -numpy<1.24.0 -matplotlib -ray<2.0.0 tensorboardX -cython -tqdm -threadpoolctl>2.2.0 -scipy +fastparquet +func-timeout gensim -rpy2 redis seaborn>=0.11.0 -fastparquet +matplotlib +tqdm +pyarrow +rpy2 +cython +ray<2.0.0 +setuptools +torch +ray[tune] +threadpoolctl>2.2.0 +numpy<1.24.0 +scikit-learn>=1.2.0 +scipy diff --git a/setup.py b/setup.py index b24b1e1..6a27ff1 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ Author: Panyi Dong (panyid2@illinois.edu) ----- -Last Modified: Wednesday, 22nd November 2023 11:20:07 pm +Last Modified: Friday, 24th November 2023 2:46:28 pm Modified By: Panyi Dong (panyid2@illinois.edu) ----- @@ -99,6 +99,7 @@ def cythonize(*args, **kwargs): "scipy", "pyarrow", "fastparquet", + "func-timeout", "matplotlib", "seaborn>=0.11.0", "ray<2.0.0",