optuna / optuna-integration

Extended functionalities for Optuna in combination with third-party libraries.
https://optuna-integration.readthedocs.io/en/latest/index.html
MIT License
39 stars 30 forks source link

OptunaSearchCV does not respect verbose flag #117

Open KiloLiuton opened 6 months ago

KiloLiuton commented 6 months ago

Expected behavior

Calling OptunaSearchCV with argument verbose=0 should not produce any verbose output to stdout, but it still prints a warning, a study creation message, and one line for every trial performed.

Environment

Error messages, stack traces, or logs

/tmp/ipykernel_1434112/215034810.py:9: ExperimentalWarning: OptunaSearchCV is experimental (supported from v0.17.0). The interface can change in the future.
  reg = optuna_integration.OptunaSearchCV(model, param_space, n_trials=2, verbose=0)
[I 2024-05-07 11:24:28,187] A new study created in memory with name: no-name-2885ec7c-3eb9-41c1-89e4-176866e4f9eb
[I 2024-05-07 11:24:28,241] Trial 0 finished with value: 0.7458922389714324 and parameters: {'alpha': 0.6304826468351286}. Best is trial 0 with value: 0.7458922389714324.
[I 2024-05-07 11:24:28,278] Trial 1 finished with value: 0.7346998198207924 and parameters: {'alpha': 0.13100756138334635}. Best is trial 0 with value: 0.7458922389714324.

Steps to reproduce

  1. install optuna, optuna_integration and sklearn
  2. run the following script
import optuna
import optuna_integration
from sklearn.datasets import make_regression
from sklearn.linear_model import Ridge

x, y = make_regression()
model = Ridge()
param_space = {"alpha": optuna.distributions.FloatDistribution(0.0, 1.0)}
reg = optuna_integration.OptunaSearchCV(model, param_space, n_trials=2, verbose=0)
reg = reg.fit(x, y)

Additional context (optional)

No response

nzw0301 commented 6 months ago

Calling OptunaSearchCV with argument verbose=0 should not produce any verbose output to stdout

Hmm, I don't think so. This argument controls OptunaSearchCV's logger, not optuna's logger as defined in the codebase. It would be great to clarify this in the docs.