Skip to content

Commit c3d8d3a

Browse files
authored
Merge branch 'main' into li/python313
2 parents af320ee + f6a5163 commit c3d8d3a

29 files changed

+53
-59
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ repos:
3636
- id: black
3737

3838
- repo: https://github.com/executablebooks/mdformat
39-
rev: 0.7.17
39+
rev: 0.7.22
4040
hooks:
4141
- id: mdformat
4242
additional_dependencies:

NOTICE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This repository incorporates material as listed below or described in the code.
44

55
## Component. Ray.
66

7-
Code in tune/\[analysis.py, sample.py, trial.py, result.py\],
8-
searcher/\[suggestion.py, variant_generator.py\], and scheduler/trial_scheduler.py is adapted from
7+
Code in tune/[analysis.py, sample.py, trial.py, result.py],
8+
searcher/[suggestion.py, variant_generator.py], and scheduler/trial_scheduler.py is adapted from
99
https://github.com/ray-project/ray/blob/master/python/ray/tune/
1010

1111
## Open Source License/Copyright Notice.

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If you believe you have found a security vulnerability in any Microsoft-owned re
1212

1313
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
1414

15-
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
15+
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
1616

1717
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
1818

flaml/automl/ml.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,14 @@ def get_y_pred(estimator, X, eval_metric, task: Task):
311311
else:
312312
y_pred = estimator.predict(X)
313313

314-
if isinstance(y_pred, Series) or isinstance(y_pred, DataFrame):
314+
if isinstance(y_pred, (Series, DataFrame)):
315315
y_pred = y_pred.values
316316

317317
return y_pred
318318

319319

320320
def to_numpy(x):
321-
if isinstance(x, Series or isinstance(x, DataFrame)):
321+
if isinstance(x, (Series, DataFrame)):
322322
x = x.values
323323
else:
324324
x = np.ndarray(x)
@@ -586,7 +586,7 @@ def _eval_estimator(
586586

587587
# TODO: why are integer labels being cast to str in the first place?
588588

589-
if isinstance(val_pred_y, Series) or isinstance(val_pred_y, DataFrame) or isinstance(val_pred_y, np.ndarray):
589+
if isinstance(val_pred_y, (Series, DataFrame, np.ndarray)):
590590
test = val_pred_y if isinstance(val_pred_y, np.ndarray) else val_pred_y.values
591591
if not np.issubdtype(test.dtype, np.number):
592592
# some NLP models return a list

flaml/automl/nlp/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ def load_default_huggingface_metric_for_task(task):
2525

2626

2727
def is_a_list_of_str(this_obj):
28-
return (isinstance(this_obj, list) or isinstance(this_obj, np.ndarray)) and all(
29-
isinstance(x, str) for x in this_obj
30-
)
28+
return isinstance(this_obj, (list, np.ndarray)) and all(isinstance(x, str) for x in this_obj)
3129

3230

3331
def _clean_value(value: Any) -> str:

flaml/automl/state.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ def valid_starting_point_one_dim(self, value_one_dim, domain_one_dim):
3737
if isinstance(domain_one_dim, sample.Domain):
3838
renamed_type = list(inspect.signature(domain_one_dim.is_valid).parameters.values())[0].annotation
3939
type_match = (
40-
renamed_type == Any
40+
renamed_type is Any
4141
or isinstance(value_one_dim, renamed_type)
42-
or isinstance(value_one_dim, int)
43-
and renamed_type is float
42+
or (renamed_type is float and isinstance(value_one_dim, int))
4443
)
4544
if not (type_match and domain_one_dim.is_valid(value_one_dim)):
4645
return False

flaml/automl/task/time_series_task.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,8 @@ def _preprocess(self, X, transformer=None):
386386
return X
387387

388388
def preprocess(self, X, transformer=None):
389-
if isinstance(X, pd.DataFrame) or isinstance(X, np.ndarray) or isinstance(X, pd.Series):
390-
X = X.copy()
391-
X = normalize_ts_data(X, self.target_names, self.time_col)
389+
if isinstance(X, (pd.DataFrame, np.ndarray, pd.Series)):
390+
X = normalize_ts_data(X.copy(), self.target_names, self.time_col)
392391
return self._preprocess(X, transformer)
393392
elif isinstance(X, int):
394393
return X

flaml/automl/time_series/ts_data.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -546,14 +546,12 @@ def normalize_ts_data(X_train_all, target_names, time_col, y_train_all=None):
546546

547547

548548
def validate_data_basic(X_train_all, y_train_all):
549-
assert isinstance(X_train_all, np.ndarray) or issparse(X_train_all) or isinstance(X_train_all, pd.DataFrame), (
550-
"X_train_all must be a numpy array, a pandas dataframe, " "or Scipy sparse matrix."
551-
)
549+
assert isinstance(X_train_all, (np.ndarray, DataFrame)) or issparse(
550+
X_train_all
551+
), "X_train_all must be a numpy array, a pandas dataframe, or Scipy sparse matrix."
552552

553-
assert (
554-
isinstance(y_train_all, np.ndarray)
555-
or isinstance(y_train_all, pd.Series)
556-
or isinstance(y_train_all, pd.DataFrame)
553+
assert isinstance(
554+
y_train_all, (np.ndarray, pd.Series, pd.DataFrame)
557555
), "y_train_all must be a numpy array or a pandas series or DataFrame."
558556

559557
assert X_train_all.size != 0 and y_train_all.size != 0, "Input data must not be empty, use None if no data"

flaml/onlineml/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ChaCha for Online AutoML
22

3-
FLAML includes *ChaCha* which is an automatic hyperparameter tuning solution for online machine learning. Online machine learning has the following properties: (1) data comes in sequential order; and (2) the performance of the machine learning model is evaluated online, i.e., at every iteration. *ChaCha* performs online AutoML respecting the aforementioned properties of online learning, and at the same time respecting the following constraints: (1) only a small constant number of 'live' models are allowed to perform online learning at the same time; and (2) no model persistence or offline training is allowed, which means that once we decide to replace a 'live' model with a new one, the replaced model can no longer be retrieved.
3+
FLAML includes *ChaCha* which is an automatic hyperparameter tuning solution for online machine learning. Online machine learning has the following properties: (1) data comes in sequential order; and (2) the performance of the machine learning model is evaluated online, i.e., at every iteration. *ChaCha* performs online AutoML respecting the aforementioned properties of online learning, and at the same time respecting the following constraints: (1) only a small constant number of 'live' models are allowed to perform online learning at the same time; and (2) no model persistence or offline training is allowed, which means that once we decide to replace a 'live' model with a new one, the replaced model can no longer be retrieved.
44

55
For more technical details about *ChaCha*, please check our paper.
66

flaml/tune/searcher/flow2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,10 @@ def config_signature(self, config, space: Dict = None) -> tuple:
641641
else:
642642
# key must be in space
643643
domain = space[key]
644-
if self.hierarchical and not (
645-
domain is None or type(domain) in (str, int, float) or isinstance(domain, sample.Domain)
644+
if (
645+
self.hierarchical
646+
and domain is not None
647+
and not isinstance(domain, (str, int, float, sample.Domain))
646648
):
647649
# not domain or hashable
648650
# get rid of list type for hierarchical search space.

0 commit comments

Comments
 (0)