FLAML 2.3.2__tar.gz → 2.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flaml-2.3.2 → flaml-2.3.4}/FLAML.egg-info/PKG-INFO +1 -1
- {flaml-2.3.2 → flaml-2.3.4}/FLAML.egg-info/SOURCES.txt +0 -1
- {flaml-2.3.2 → flaml-2.3.4}/PKG-INFO +1 -1
- {flaml-2.3.2 → flaml-2.3.4}/flaml/__init__.py +4 -2
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/automl.py +3 -3
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/model.py +16 -11
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/task/generic_task.py +5 -5
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/task/task.py +1 -1
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/tune.py +19 -2
- flaml-2.3.4/flaml/version.py +1 -0
- {flaml-2.3.2 → flaml-2.3.4}/test/test_gpu.py +11 -0
- flaml-2.3.2/flaml/version.py +0 -1
- flaml-2.3.2/test/test_model.py +0 -146
- {flaml-2.3.2 → flaml-2.3.4}/FLAML.egg-info/dependency_links.txt +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/FLAML.egg-info/requires.txt +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/FLAML.egg-info/top_level.txt +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/LICENSE +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/NOTICE.md +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/README.md +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/agentchat/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/agentchat/agent.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/agentchat/assistant_agent.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/agentchat/conversable_agent.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/agentchat/groupchat.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/agentchat/user_proxy_agent.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/code_utils.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/extensions/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/math_utils.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/oai/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/oai/completion.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/oai/openai_utils.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/autogen/retrieve_utils.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/contrib/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/contrib/histgb.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/data.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/logger.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/ml.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/nlp/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/nlp/huggingface/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/nlp/huggingface/data_collator.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/nlp/huggingface/trainer.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/nlp/huggingface/training_args.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/nlp/huggingface/utils.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/nlp/utils.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/spark/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/spark/metrics.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/spark/utils.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/state.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/task/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/task/factory.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/task/time_series_task.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/time_series/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/time_series/feature.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/time_series/sklearn.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/time_series/tcn.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/time_series/tft.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/time_series/ts_data.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/time_series/ts_model.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/automl/training_log.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/config.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/all/binary.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/all/multiclass.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/all/regression.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/estimator.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/extra_tree/binary.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/extra_tree/multiclass.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/extra_tree/regression.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/greedy.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/lgbm/binary.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/lgbm/multiclass.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/lgbm/regression.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/portfolio.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/regret.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/rf/binary.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/rf/multiclass.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/rf/regression.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/suggest.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/xgb_limitdepth/binary.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/xgb_limitdepth/multiclass.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/xgb_limitdepth/regression.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/xgboost/binary.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/xgboost/multiclass.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/default/xgboost/regression.json +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/fabric/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/fabric/mlflow.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/ml.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/onlineml/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/onlineml/autovw.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/onlineml/trial.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/onlineml/trial_runner.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/analysis.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/result.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/sample.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/scheduler/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/scheduler/online_scheduler.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/scheduler/trial_scheduler.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/searcher/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/searcher/blendsearch.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/searcher/cfo_cat.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/searcher/flow2.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/searcher/online_searcher.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/searcher/search_thread.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/searcher/suggestion.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/searcher/variant_generator.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/space.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/spark/__init__.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/spark/utils.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/trial.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/trial_runner.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/flaml/tune/utils.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/pyproject.toml +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/setup.cfg +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/setup.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/test/test_autovw.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/test/test_conda_distribution.py +0 -0
- {flaml-2.3.2 → flaml-2.3.4}/test/test_version.py +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
import warnings
|
|
2
3
|
|
|
3
4
|
try:
|
|
4
5
|
from flaml.automl import AutoML, logger_formatter
|
|
@@ -12,7 +13,8 @@ from flaml.version import __version__
|
|
|
12
13
|
|
|
13
14
|
# Set the root logger.
|
|
14
15
|
logger = logging.getLogger(__name__)
|
|
15
|
-
logger.
|
|
16
|
+
if logger.level == logging.NOTSET:
|
|
17
|
+
logger.setLevel(logging.INFO)
|
|
16
18
|
|
|
17
19
|
if not has_automl:
|
|
18
|
-
|
|
20
|
+
warnings.warn("flaml.automl is not available. Please install flaml[automl] to enable AutoML functionalities.")
|
|
@@ -203,7 +203,7 @@ class AutoML(BaseEstimator):
|
|
|
203
203
|
* Valid str options depend on different tasks.
|
|
204
204
|
For classification tasks, valid choices are
|
|
205
205
|
["auto", 'stratified', 'uniform', 'time', 'group']. "auto" -> stratified.
|
|
206
|
-
For regression tasks, valid choices are ["auto", 'uniform', 'time'].
|
|
206
|
+
For regression tasks, valid choices are ["auto", 'uniform', 'time', 'group'].
|
|
207
207
|
"auto" -> uniform.
|
|
208
208
|
For time series forecast tasks, must be "auto" or 'time'.
|
|
209
209
|
For ranking task, must be "auto" or 'group'.
|
|
@@ -739,7 +739,7 @@ class AutoML(BaseEstimator):
|
|
|
739
739
|
* Valid str options depend on different tasks.
|
|
740
740
|
For classification tasks, valid choices are
|
|
741
741
|
["auto", 'stratified', 'uniform', 'time', 'group']. "auto" -> stratified.
|
|
742
|
-
For regression tasks, valid choices are ["auto", 'uniform', 'time'].
|
|
742
|
+
For regression tasks, valid choices are ["auto", 'uniform', 'time', 'group'].
|
|
743
743
|
"auto" -> uniform.
|
|
744
744
|
For time series forecast tasks, must be "auto" or 'time'.
|
|
745
745
|
For ranking task, must be "auto" or 'group'.
|
|
@@ -1358,7 +1358,7 @@ class AutoML(BaseEstimator):
|
|
|
1358
1358
|
* Valid str options depend on different tasks.
|
|
1359
1359
|
For classification tasks, valid choices are
|
|
1360
1360
|
["auto", 'stratified', 'uniform', 'time', 'group']. "auto" -> stratified.
|
|
1361
|
-
For regression tasks, valid choices are ["auto", 'uniform', 'time'].
|
|
1361
|
+
For regression tasks, valid choices are ["auto", 'uniform', 'time', 'group'].
|
|
1362
1362
|
"auto" -> uniform.
|
|
1363
1363
|
For time series forecast tasks, must be "auto" or 'time'.
|
|
1364
1364
|
For ranking task, must be "auto" or 'group'.
|
|
@@ -9,6 +9,7 @@ import os
|
|
|
9
9
|
import shutil
|
|
10
10
|
import signal
|
|
11
11
|
import sys
|
|
12
|
+
import threading
|
|
12
13
|
import time
|
|
13
14
|
import warnings
|
|
14
15
|
from contextlib import contextmanager
|
|
@@ -89,21 +90,25 @@ def limit_resource(memory_limit, time_limit):
|
|
|
89
90
|
except ValueError:
|
|
90
91
|
# According to https://bugs.python.org/issue40518, it's a mac-specific error.
|
|
91
92
|
pass
|
|
92
|
-
|
|
93
|
-
if time_limit is not None:
|
|
93
|
+
alarm_set = False
|
|
94
|
+
if time_limit is not None and threading.current_thread() is threading.main_thread():
|
|
94
95
|
try:
|
|
95
96
|
signal.signal(signal.SIGALRM, TimeoutHandler)
|
|
96
97
|
signal.alarm(int(time_limit) or 1)
|
|
97
|
-
|
|
98
|
+
alarm_set = True
|
|
98
99
|
except ValueError:
|
|
99
100
|
pass
|
|
101
|
+
|
|
100
102
|
try:
|
|
101
103
|
yield
|
|
102
104
|
finally:
|
|
103
|
-
if
|
|
105
|
+
if alarm_set:
|
|
104
106
|
signal.alarm(0)
|
|
105
107
|
if memory_limit > 0:
|
|
106
|
-
|
|
108
|
+
try:
|
|
109
|
+
resource.setrlimit(resource.RLIMIT_AS, (soft, hard))
|
|
110
|
+
except ValueError:
|
|
111
|
+
pass
|
|
107
112
|
|
|
108
113
|
|
|
109
114
|
class BaseEstimator:
|
|
@@ -130,7 +135,7 @@ class BaseEstimator:
|
|
|
130
135
|
self._task = task if isinstance(task, Task) else task_factory(task, None, None)
|
|
131
136
|
self.params = self.config2params(config)
|
|
132
137
|
self.estimator_class = self._model = None
|
|
133
|
-
if "_estimator_type" in
|
|
138
|
+
if "_estimator_type" in self.params:
|
|
134
139
|
self._estimator_type = self.params.pop("_estimator_type")
|
|
135
140
|
else:
|
|
136
141
|
self._estimator_type = "classifier" if self._task.is_classification() else "regressor"
|
|
@@ -1691,7 +1696,7 @@ class XGBoostEstimator(SKLearnEstimator):
|
|
|
1691
1696
|
# use_label_encoder is deprecated in 1.7.
|
|
1692
1697
|
if xgboost_version < "1.7.0":
|
|
1693
1698
|
params["use_label_encoder"] = params.get("use_label_encoder", False)
|
|
1694
|
-
if "n_jobs" in
|
|
1699
|
+
if "n_jobs" in params:
|
|
1695
1700
|
params["nthread"] = params.pop("n_jobs")
|
|
1696
1701
|
return params
|
|
1697
1702
|
|
|
@@ -1891,7 +1896,7 @@ class RandomForestEstimator(SKLearnEstimator, LGBMEstimator):
|
|
|
1891
1896
|
params = super().config2params(config)
|
|
1892
1897
|
if "max_leaves" in params:
|
|
1893
1898
|
params["max_leaf_nodes"] = params.get("max_leaf_nodes", params.pop("max_leaves"))
|
|
1894
|
-
if not self._task.is_classification() and "criterion" in
|
|
1899
|
+
if not self._task.is_classification() and "criterion" in params:
|
|
1895
1900
|
params.pop("criterion")
|
|
1896
1901
|
if "random_state" not in params:
|
|
1897
1902
|
params["random_state"] = 12032022
|
|
@@ -2066,8 +2071,8 @@ class CatBoostEstimator(BaseEstimator):
|
|
|
2066
2071
|
self.estimator_class = CatBoostRegressor
|
|
2067
2072
|
|
|
2068
2073
|
def fit(self, X_train, y_train, budget=None, free_mem_ratio=0, **kwargs):
|
|
2069
|
-
|
|
2070
|
-
|
|
2074
|
+
kwargs.pop("is_retrain", None)
|
|
2075
|
+
kwargs.pop("groups", None)
|
|
2071
2076
|
start_time = time.time()
|
|
2072
2077
|
deadline = start_time + budget if budget else np.inf
|
|
2073
2078
|
train_dir = f"catboost_{str(start_time)}"
|
|
@@ -2344,7 +2349,7 @@ class SGDEstimator(SKLearnEstimator):
|
|
|
2344
2349
|
params["loss"] = params.get("loss", None)
|
|
2345
2350
|
if params["loss"] is None and self._task.is_classification():
|
|
2346
2351
|
params["loss"] = "log_loss" if SKLEARN_VERSION >= "1.1" else "log"
|
|
2347
|
-
if not self._task.is_classification():
|
|
2352
|
+
if not self._task.is_classification() and "n_jobs" in params:
|
|
2348
2353
|
params.pop("n_jobs")
|
|
2349
2354
|
|
|
2350
2355
|
if params.get("penalty") != "elasticnet":
|
|
@@ -442,8 +442,8 @@ class GenericTask(Task):
|
|
|
442
442
|
X_train_all, y_train_all = shuffle(X_train_all, y_train_all, random_state=RANDOM_SEED)
|
|
443
443
|
if data_is_df:
|
|
444
444
|
X_train_all.reset_index(drop=True, inplace=True)
|
|
445
|
-
|
|
446
|
-
|
|
445
|
+
if isinstance(y_train_all, pd.Series):
|
|
446
|
+
y_train_all.reset_index(drop=True, inplace=True)
|
|
447
447
|
|
|
448
448
|
X_train, y_train = X_train_all, y_train_all
|
|
449
449
|
state.groups_all = state.groups
|
|
@@ -769,10 +769,10 @@ class GenericTask(Task):
|
|
|
769
769
|
if not is_spark_dataframe:
|
|
770
770
|
y_train, y_val = y_train_split[train_index], y_train_split[val_index]
|
|
771
771
|
if weight is not None:
|
|
772
|
-
fit_kwargs["sample_weight"]
|
|
773
|
-
weight[train_index],
|
|
774
|
-
weight[val_index],
|
|
772
|
+
fit_kwargs["sample_weight"] = (
|
|
773
|
+
weight[train_index] if isinstance(weight, np.ndarray) else weight.iloc[train_index]
|
|
775
774
|
)
|
|
775
|
+
weight_val = weight[val_index] if isinstance(weight, np.ndarray) else weight.iloc[val_index]
|
|
776
776
|
if groups is not None:
|
|
777
777
|
fit_kwargs["groups"] = (
|
|
778
778
|
groups[train_index] if isinstance(groups, np.ndarray) else groups.iloc[train_index]
|
|
@@ -192,7 +192,7 @@ class Task(ABC):
|
|
|
192
192
|
* Valid str options depend on different tasks.
|
|
193
193
|
For classification tasks, valid choices are
|
|
194
194
|
["auto", 'stratified', 'uniform', 'time', 'group']. "auto" -> stratified.
|
|
195
|
-
For regression tasks, valid choices are ["auto", 'uniform', 'time'].
|
|
195
|
+
For regression tasks, valid choices are ["auto", 'uniform', 'time', 'group'].
|
|
196
196
|
"auto" -> uniform.
|
|
197
197
|
For time series forecast tasks, must be "auto" or 'time'.
|
|
198
198
|
For ranking task, must be "auto" or 'group'.
|
|
@@ -197,9 +197,16 @@ def report(_metric=None, **kwargs):
|
|
|
197
197
|
global _training_iteration
|
|
198
198
|
if _use_ray:
|
|
199
199
|
try:
|
|
200
|
-
from ray import
|
|
200
|
+
from ray import __version__ as ray_version
|
|
201
|
+
|
|
202
|
+
if ray_version.startswith("1."):
|
|
203
|
+
from ray import tune
|
|
204
|
+
|
|
205
|
+
return tune.report(_metric, **kwargs)
|
|
206
|
+
else: # ray>=2
|
|
207
|
+
from ray.air import session
|
|
201
208
|
|
|
202
|
-
|
|
209
|
+
return session.report(metrics={"metric": _metric, **kwargs})
|
|
203
210
|
except ImportError:
|
|
204
211
|
# calling tune.report() outside tune.run()
|
|
205
212
|
return
|
|
@@ -260,6 +267,8 @@ def run(
|
|
|
260
267
|
mlflow_exp_name: Optional[str] = None,
|
|
261
268
|
automl_info: Optional[Tuple[float]] = None,
|
|
262
269
|
extra_tag: Optional[dict] = None,
|
|
270
|
+
cost_attr: Optional[str] = "auto",
|
|
271
|
+
cost_budget: Optional[float] = None,
|
|
263
272
|
**ray_args,
|
|
264
273
|
):
|
|
265
274
|
"""The function-based way of performing HPO.
|
|
@@ -462,6 +471,12 @@ def run(
|
|
|
462
471
|
overwritten by the value of `n_concurrent_trials` in AutoML. When <= 0, the concurrent trials
|
|
463
472
|
will be set to the number of executors.
|
|
464
473
|
extra_tag: dict, default=None | Extra tags to be added to the mlflow runs created by autologging.
|
|
474
|
+
cost_attr: None or str to specify the attribute to evaluate the cost of different trials.
|
|
475
|
+
Default is "auto", which means that we will automatically choose the cost attribute to use (depending
|
|
476
|
+
on the nature of the resource budget). When cost_attr is set to None, cost differences between different trials will be omitted
|
|
477
|
+
in our search algorithm. When cost_attr is set to a str different from "auto" and "time_total_s",
|
|
478
|
+
this cost_attr must be available in the result dict of the trial.
|
|
479
|
+
cost_budget: A float of the cost budget. Only valid when cost_attr is a str different from "auto" and "time_total_s".
|
|
465
480
|
**ray_args: keyword arguments to pass to ray.tune.run().
|
|
466
481
|
Only valid when use_ray=True.
|
|
467
482
|
"""
|
|
@@ -600,6 +615,8 @@ def run(
|
|
|
600
615
|
metric_constraints=metric_constraints,
|
|
601
616
|
use_incumbent_result_in_evaluation=use_incumbent_result_in_evaluation,
|
|
602
617
|
lexico_objectives=lexico_objectives,
|
|
618
|
+
cost_attr=cost_attr,
|
|
619
|
+
cost_budget=cost_budget,
|
|
603
620
|
)
|
|
604
621
|
else:
|
|
605
622
|
if metric is None or mode is None:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.3.4"
|
|
@@ -59,6 +59,17 @@ def _test_hf_data():
|
|
|
59
59
|
except requests.exceptions.ConnectionError:
|
|
60
60
|
return
|
|
61
61
|
|
|
62
|
+
# Tests will only run if there is a GPU available
|
|
63
|
+
try:
|
|
64
|
+
import ray
|
|
65
|
+
|
|
66
|
+
pg = ray.util.placement_group([{"CPU": 1, "GPU": 1}])
|
|
67
|
+
|
|
68
|
+
if not pg.wait(timeout_seconds=10): # Wait 10 seconds for resources
|
|
69
|
+
raise RuntimeError("No available node types can fulfill resource request!")
|
|
70
|
+
except RuntimeError:
|
|
71
|
+
return
|
|
72
|
+
|
|
62
73
|
custom_sent_keys = ["sentence1", "sentence2"]
|
|
63
74
|
label_key = "label"
|
|
64
75
|
|
flaml-2.3.2/flaml/version.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.3.2"
|
flaml-2.3.2/test/test_model.py
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
from pandas import DataFrame
|
|
5
|
-
from sklearn.datasets import make_classification
|
|
6
|
-
|
|
7
|
-
from flaml.automl.contrib.histgb import HistGradientBoostingEstimator
|
|
8
|
-
from flaml.automl.model import (
|
|
9
|
-
BaseEstimator,
|
|
10
|
-
CatBoostEstimator,
|
|
11
|
-
KNeighborsEstimator,
|
|
12
|
-
LGBMEstimator,
|
|
13
|
-
LRL2Classifier,
|
|
14
|
-
RandomForestEstimator,
|
|
15
|
-
XGBoostEstimator,
|
|
16
|
-
)
|
|
17
|
-
from flaml.automl.time_series import ARIMA, LGBM_TS, Prophet, TimeSeriesDataset
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def test_lrl2():
|
|
21
|
-
BaseEstimator.search_space(1, "")
|
|
22
|
-
X, y = make_classification(100000, 1000)
|
|
23
|
-
print("start")
|
|
24
|
-
lr = LRL2Classifier()
|
|
25
|
-
lr.predict(X)
|
|
26
|
-
lr.fit(X, y, budget=1e-5)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def test_prep():
|
|
30
|
-
X = np.array(
|
|
31
|
-
list(
|
|
32
|
-
zip(
|
|
33
|
-
[
|
|
34
|
-
3.0,
|
|
35
|
-
16.0,
|
|
36
|
-
10.0,
|
|
37
|
-
12.0,
|
|
38
|
-
3.0,
|
|
39
|
-
14.0,
|
|
40
|
-
11.0,
|
|
41
|
-
12.0,
|
|
42
|
-
5.0,
|
|
43
|
-
14.0,
|
|
44
|
-
20.0,
|
|
45
|
-
16.0,
|
|
46
|
-
15.0,
|
|
47
|
-
11.0,
|
|
48
|
-
],
|
|
49
|
-
[
|
|
50
|
-
"a",
|
|
51
|
-
"b",
|
|
52
|
-
"a",
|
|
53
|
-
"c",
|
|
54
|
-
"c",
|
|
55
|
-
"b",
|
|
56
|
-
"b",
|
|
57
|
-
"b",
|
|
58
|
-
"b",
|
|
59
|
-
"a",
|
|
60
|
-
"b",
|
|
61
|
-
1.0,
|
|
62
|
-
1.0,
|
|
63
|
-
"a",
|
|
64
|
-
],
|
|
65
|
-
)
|
|
66
|
-
),
|
|
67
|
-
dtype=object,
|
|
68
|
-
)
|
|
69
|
-
y = np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1])
|
|
70
|
-
lr = LRL2Classifier()
|
|
71
|
-
lr.fit(X, y)
|
|
72
|
-
lr.predict(X)
|
|
73
|
-
print(lr.feature_names_in_)
|
|
74
|
-
print(lr.feature_importances_)
|
|
75
|
-
lgbm = LGBMEstimator(n_estimators=4)
|
|
76
|
-
lgbm.fit(X, y)
|
|
77
|
-
print(lgbm.feature_names_in_)
|
|
78
|
-
print(lgbm.feature_importances_)
|
|
79
|
-
cat = CatBoostEstimator(n_estimators=4)
|
|
80
|
-
cat.fit(X, y)
|
|
81
|
-
print(cat.feature_names_in_)
|
|
82
|
-
print(cat.feature_importances_)
|
|
83
|
-
knn = KNeighborsEstimator(task="regression")
|
|
84
|
-
knn.fit(X, y)
|
|
85
|
-
print(knn.feature_names_in_)
|
|
86
|
-
print(knn.feature_importances_)
|
|
87
|
-
xgb = XGBoostEstimator(n_estimators=4, max_leaves=4)
|
|
88
|
-
xgb.fit(X, y)
|
|
89
|
-
xgb.predict(X)
|
|
90
|
-
print(xgb.feature_names_in_)
|
|
91
|
-
print(xgb.feature_importances_)
|
|
92
|
-
rf = RandomForestEstimator(task="regression", n_estimators=4, criterion="gini")
|
|
93
|
-
rf.fit(X, y)
|
|
94
|
-
print(rf.feature_names_in_)
|
|
95
|
-
print(rf.feature_importances_)
|
|
96
|
-
hgb = HistGradientBoostingEstimator(task="regression", n_estimators=4, max_leaves=4)
|
|
97
|
-
hgb.fit(X, y)
|
|
98
|
-
hgb.predict(X)
|
|
99
|
-
print(hgb.feature_names_in_)
|
|
100
|
-
print(hgb.feature_importances_)
|
|
101
|
-
|
|
102
|
-
prophet = Prophet()
|
|
103
|
-
try:
|
|
104
|
-
prophet.predict(4)
|
|
105
|
-
except ValueError:
|
|
106
|
-
# predict() with steps is only supported for arima/sarimax.
|
|
107
|
-
pass
|
|
108
|
-
prophet.predict(X)
|
|
109
|
-
|
|
110
|
-
# What's the point of callin ARIMA without parameters, or calling predict before fit?
|
|
111
|
-
arima = ARIMA(p=1, q=1, d=0)
|
|
112
|
-
arima.predict(X)
|
|
113
|
-
arima._model = False
|
|
114
|
-
try:
|
|
115
|
-
arima.predict(X)
|
|
116
|
-
except ValueError:
|
|
117
|
-
# X_test needs to be either a pandas Dataframe with dates as the first column or an int number of periods for predict().
|
|
118
|
-
pass
|
|
119
|
-
lgbm = LGBM_TS(lags=1)
|
|
120
|
-
X = DataFrame(
|
|
121
|
-
{
|
|
122
|
-
"A": [
|
|
123
|
-
datetime(1900, 3, 1),
|
|
124
|
-
datetime(1900, 3, 2),
|
|
125
|
-
datetime(1900, 3, 3),
|
|
126
|
-
datetime(1900, 3, 4),
|
|
127
|
-
datetime(1900, 3, 4),
|
|
128
|
-
datetime(1900, 3, 4),
|
|
129
|
-
datetime(1900, 3, 5),
|
|
130
|
-
datetime(1900, 3, 6),
|
|
131
|
-
],
|
|
132
|
-
}
|
|
133
|
-
)
|
|
134
|
-
y = np.array([0, 1, 0, 1, 1, 1, 0, 0])
|
|
135
|
-
lgbm.predict(X[:2])
|
|
136
|
-
df = X.copy()
|
|
137
|
-
df["y"] = y
|
|
138
|
-
tsds = TimeSeriesDataset(df, time_col="A", target_names="y")
|
|
139
|
-
lgbm.fit(tsds, period=2)
|
|
140
|
-
lgbm.predict(X[:2])
|
|
141
|
-
print(lgbm.feature_names_in_)
|
|
142
|
-
print(lgbm.feature_importances_)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if __name__ == "__main__":
|
|
146
|
-
test_prep()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|