Repository: optuna/optuna

Issue:
Add test to ensure LightGBMTuner's default arguments and LightGBM's arguments consistent
<!-- Please write a clear and concise description of the feature proposal. -->

## Motivation

Users suppose that LightGBMTuners follow the original methods' default arguments. To automatically detect the updates of the original methods, it would be great to add a test to check the Optuna's method are consistent with the original one.

## Description

Please add the test that ensures the default argument values are the same as the LightGBM's corresponding value to [`lightgbm_tuner_tests/test_optimize.py`](https://github.com/optuna/optuna/blob/master/tests/integration_tests/lightgbm_tuner_tests/test_optimize.py). More concretely, the following combination 

- [`LightGBMTuner`](https://optuna.readthedocs.io/en/stable/reference/generated/optuna.integration.lightgbm.LightGBMTuner.html#optuna-integration-lightgbm-lightgbmtuner) and [`lightgbm.train`](https://lightgbm.readthedocs.io/en/latest/pythonapi/lightgbm.train.html)
- [`LightGBMTunerCV`](https://optuna.readthedocs.io/en/stable/reference/generated/optuna.integration.lightgbm.LightGBMTunerCV.html#optuna.integration.lightgbm.LightGBMTunerCV) and [`lightgbm.cv`](https://lightgbm.readthedocs.io/en/latest/pythonapi/lightgbm.cv.html)
<!-- Please write a detailed description of the new feature. -->

## Alternatives (optional)

<!-- Please write a clear and concise description of any alternative solutions or features you've considered. -->

## Additional context (optional)

<!-- Please add any other context or screenshots about the feature request here. -->



Discussion:
Hello! I would like to work on this issue. 

I was able to get the default values from LightGBMTuner arguments by accessing the attribute `lgbm_kwargs`. 

The code
```
import optuna
import numpy as np
from optuna.integration._lightgbm_tuner.optimize import _BaseTuner
from optuna.integration._lightgbm_tuner.optimize import _OptunaObjective
from optuna.integration._lightgbm_tuner.optimize import _OptunaObjectiveCV
from optuna.integration._lightgbm_tuner.optimize import LightGBMTuner
from optuna.integration._lightgbm_tuner.optimize import LightGBMTunerCV
import optuna.integration.lightgbm as lgb
from typing import Dict

train_dataset = lgb.Dataset(np.zeros((10, 10)))
valid_dataset = lgb.Dataset(np.zeros((10, 10)))
params: Dict = {}
runner = lgb.LightGBMTuner(
                params,
                train_dataset,
                valid_sets=[valid_dataset]
            )
runner.lgbm_kwargs
```

Output
```
{'callbacks': None,
 'categorical_feature': 'auto',
 'early_stopping_rounds': None,
 'evals_result': None,
 'feature_name': 'auto',
 'feval': None,
 'fobj': None,
 'keep_training_booster': False,
 'learning_rates': None,
 'num_boost_round': 1000,
 'valid_names': None,
 'valid_sets': [<lightgbm.basic.Dataset at 0x7f9fdcb41590>],
 'verbose_eval': True}
```

However, I was not able to find the way to get the default value parameters from the original LightGBM. I tried accessing it through their method `attr()`, but instead I only get the empty object. In addition, I tried accessing it through the attribute of `Booster` class 
```
import lightgbm as lgb1
model = lgb1.train(params, train_dataset)
model._Booster__attr
```
I only got two attributes
```
{'early_stopping_round': None, 'num_iterations': 100}
```

@nzw0301 Could you help me please with getting default values of original LightGBM. Am I on the right path tackling the problem?


Hi, thank you for trying to resolve this issue!

I think `inspect.signature` can access the method's default values without initialisation.

For example, to access `lightgbm.train`'s default argument values, we can use the following snippet.

```python
import lightgbm
from inspect import signature

for k, v in signature(lightgbm.train).parameters.items():
    print(k, v.default)
```

The outputs are as follows:
```
params <class 'inspect._empty'>
train_set <class 'inspect._empty'>
num_boost_round 100
valid_sets None
valid_names None
fobj None
feval None
init_model None
feature_name auto
categorical_feature auto
early_stopping_rounds None
evals_result None
verbose_eval True
learning_rates None
keep_training_booster False
callbacks None
```

Similarly we can access `LightGBMTuner`'s ones by using `signature(optuna.integration.lightgbm.LightGBMTuner)`.

Hello! I have tried to run the testing script using the command 
```
pytest tests/integration_tests/lightgbm_tuner_tests/test_optimize.py
```
And ran into this issue.
<img width="1106" alt="image" src="https://user-images.githubusercontent.com/55283735/139528889-4b3dfe3b-67c1-4c24-ae9a-76f14fe7aa29.png">

Could you help me resolve this issue? 
What I have done:
1. Created virtual environment 
2. Installed Optuna using `pip install -e .`
3. Run the command `pytest tests/integration_tests/lightgbm_tuner_tests/test_optimize.py`

could you install `colorlog` by using `pip install colorlog`. By the way, it would be helpful to share the output as text rather than a screenshot.
@nzw0301  My issue has been resolved. I have used a Docker container. Now I am starting working on the issue! 
Brilliant! I'm looking forward to reviewing your PR!

Resolving patch:
diff --git a/optuna/integration/_lightgbm_tuner/optimize.py b/optuna/integration/_lightgbm_tuner/optimize.py
--- a/optuna/integration/_lightgbm_tuner/optimize.py
+++ b/optuna/integration/_lightgbm_tuner/optimize.py
@@ -17,7 +17,6 @@
 import warnings
 
 import numpy as np
-from packaging import version
 import tqdm
 
 import optuna
@@ -990,7 +989,7 @@ def __init__(
         verbosity: Optional[int] = None,
         show_progress_bar: bool = True,
         model_dir: Optional[str] = None,
-        return_cvbooster: Optional[bool] = None,
+        return_cvbooster: bool = False,
         *,
         optuna_seed: Optional[int] = None,
     ) -> None:
@@ -1023,10 +1022,7 @@ def __init__(
         self.lgbm_kwargs["show_stdv"] = show_stdv
         self.lgbm_kwargs["seed"] = seed
         self.lgbm_kwargs["fpreproc"] = fpreproc
-        if return_cvbooster is not None:
-            if version.parse(lgb.__version__) < version.parse("3.0.0"):
-                raise ValueError("return_cvbooster requires lightgbm>=3.0.0.")
-            self.lgbm_kwargs["return_cvbooster"] = return_cvbooster
+        self.lgbm_kwargs["return_cvbooster"] = return_cvbooster
 
     def _create_objective(
         self,


Test patch: