Skip to content

Commit c60f929

Browse files
Copilotthinkall
andauthored
Document LightGBM quantile regression setup (#1535)
Agent-Logs-Url: https://github.com/microsoft/FLAML/sessions/95732fef-8726-4bc7-a6f5-86f94270d834 Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: thinkall <3197038+thinkall@users.noreply.github.com> Co-authored-by: Li Jiang <bnujli@gmail.com>
1 parent 3f8165b commit c60f929

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

website/docs/Use-Cases/Task-Oriented-AutoML.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,51 @@ custom_hp = {
392392
}
393393
```
394394

395+
You can also use `custom_hp` to pass fixed constructor arguments to an estimator. For example, to optimize a
396+
LightGBM quantile regression model for the 0.75 quantile, use the regression task, restrict the estimator list to
397+
`lgbm`, set LightGBM's `objective` and `alpha`, and provide a custom metric that FLAML can minimize:
398+
399+
```python
400+
from flaml import AutoML
401+
from sklearn.metrics import mean_pinball_loss
402+
403+
alpha = 0.75
404+
405+
406+
def quantile_loss(
407+
X_val,
408+
y_val,
409+
estimator,
410+
labels,
411+
X_train,
412+
y_train,
413+
weight_val=None,
414+
weight_train=None,
415+
*args,
416+
**kwargs,
417+
):
418+
pred = estimator.predict(X_val)
419+
loss = mean_pinball_loss(y_val, pred, alpha=alpha, sample_weight=weight_val)
420+
return loss, {"quantile_loss": loss}
421+
422+
423+
automl = AutoML()
424+
automl.fit(
425+
X_train=X_train,
426+
y_train=y_train,
427+
task="regression",
428+
metric=quantile_loss,
429+
estimator_list=["lgbm"],
430+
time_budget=30,
431+
custom_hp={
432+
"lgbm": {
433+
"objective": {"domain": "quantile"},
434+
"alpha": {"domain": alpha},
435+
}
436+
},
437+
)
438+
```
439+
395440
### Constraint
396441

397442
There are several types of constraints you can impose.

0 commit comments

Comments
 (0)