Simplify lgbm example (#358)

* simplify lgbm examples

* provide link to lgbm example script.

* simply lgbm example in the example script.

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
This commit is contained in:
Rui Zhuang
2021-12-23 23:05:14 -08:00
committed by GitHub
parent dcfd218108
commit c6c0c29769
3 changed files with 4 additions and 6 deletions

View File

@@ -49,10 +49,9 @@ from flaml.model import LGBMEstimator
def train_lgbm(config: dict) -> dict:
# convert config dict to lgbm params
params = LGBMEstimator(**config).params
num_boost_round = params.pop("n_estimators")
# train the model
train_set = lightgbm.Dataset(X_train, y_train)
model = lightgbm.train(params, train_set, num_boost_round)
model = lightgbm.train(params, train_set)
# evaluate the model
pred = model.predict(X_test)
mse = mean_squared_error(y_test, pred)
@@ -75,6 +74,7 @@ analysis = tune.run(
low_cost_partial_config=low_cost_partial_config, time_budget_s=3, num_samples=-1,
)
```
Please see this [script](https://github.com/microsoft/FLAML/blob/main/test/tune.py) for the complete version of the above example.
### Where to Go Next?