FLAML icon indicating copy to clipboard operation
FLAML copied to clipboard

BlendSearch in UDF mode

Open khosravym opened this issue 1 year ago • 6 comments

When I select the BlendSearch search algorithm, I consistently encounter the following warning, whereas it does not appear when using CFO:

You passed a space parameter to OptunaSearch that contained unresolved search space definitions. OptunaSearch should however be instantiated with fully configured search spaces only. To use Ray Tune's automatic search space conversion, pass the space definition as part of the param_space argument to tune.Tuner() instead.

khosravym avatar Feb 25 '24 22:02 khosravym

Union[ Dict[str, "OptunaDistribution"], List[Tuple], Callable[["OptunaTrial"], Optional[Dict[str, Any]]], ]

The above is the space parameter structure that is expected could you check with what you pass to BlendSearch? and if possible send it...?

Programmer-RD-AI avatar May 22 '24 07:05 Programmer-RD-AI

I got the same warning. I used the code in this example https://github.com/microsoft/FLAML/blob/main/test/tune_example.py

Nevermetyou65 avatar Jun 22 '24 08:06 Nevermetyou65

I belive that Passing the space definition as part of the param_space argument to tune.Tuner() when using BlendSearch with OptunaSearch in UDF mode should resolve this issue...

Programmer-RD-AI avatar Jun 22 '24 09:06 Programmer-RD-AI

Sorry, But what argument are you referring to? I can not find anything about tune.Tuner() in the doc. Is it in this doc? https://microsoft.github.io/FLAML/docs/reference/tune/tune

Do you have any code example? Thanks

Nevermetyou65 avatar Jun 22 '24 14:06 Nevermetyou65

Hi, I was thinking of something similar to the following code segment:

from flaml.tune import tune

# Define the parameter space for tuning
param_space = {
    "n_estimators": tune.randint(lower=4, upper=1024),
    "num_leaves": tune.randint(lower=4, upper=1024),
    "min_child_samples": tune.randint(lower=2, upper=100),
}

# Define the settings for the AutoML run
settings = {
    ...,
    "config": param_space,
}

# Run the AutoML search
automl.fit(X_train=X_train, y_train=y_train, **settings)```

Programmer-RD-AI avatar Jun 23 '24 06:06 Programmer-RD-AI

Hmm...

I got the warning from this example: https://github.com/microsoft/FLAML/blob/main/test/tune_example.py It does not use automl.fit but tune.run() for a user-defined function. But looking at your code, I see it's the same thing. The dictionary setting should work the same as this line.

analysis = tune.run(
        train_lgbm,
        metric="mse",
        mode="min",
        config=config_search_space,
        low_cost_partial_config=low_cost_partial_config,
        points_to_evaluate=points_to_evaluate,
        time_budget_s=3,
        num_samples=-1,
    )

And that is where I got warning. Set search_alg = "CFO" as make waning gone though.

Nevermetyou65 avatar Jun 23 '24 07:06 Nevermetyou65