Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dask scikit-learn API: TypeError: fit() got an unexpected keyword argument 'callbacks' #6468

Closed
pseudotensor opened this issue Dec 5, 2020 · 10 comments

Comments

@pseudotensor
Copy link
Contributor

pseudotensor commented Dec 5, 2020

Is there planned support for dask to have callbacks? When using things like Optuna I hit:

  File "/home/jon/h2oai.fullcondatest/h2oaicore/models.py", line 1512, in objective
    model.fit(X, y, sample_weight=sample_weight, callbacks=[pruning_callback], **kwargs_fit)
  File "/home/jon/minicondadai/lib/python3.6/site-packages/xgboost/core.py", line 421, in inner_f
    return f(**kwargs)
TypeError: fit() got an unexpected keyword argument 'callbacks'

@trivialfis

@hcho3
Copy link
Collaborator

hcho3 commented Dec 5, 2020

It is already supported:

xgb.dask.train(client, {}, dtrain, num_boost_round=4, callbacks=[TestCallback()])[
'booster']

@pseudotensor
Copy link
Contributor Author

Is the scikit-learn API not supporting it? I'm using latest 1.3.0 master.

@hcho3
Copy link
Collaborator

hcho3 commented Dec 5, 2020

Not yet, currently, you'd need to use xgb.dask.train() to use the callbacks argument.

@hcho3
Copy link
Collaborator

hcho3 commented Dec 5, 2020

Also, Optuna's pruning callback function doesn't yet work with xgboost.dask: #6323. We recently overhauled the callback interface, specifically to support Dask interface, and the Optuna's pruning callback should be updated to use the new callback interface (it's using the old interface).

@pseudotensor
Copy link
Contributor Author

Ok, so even if I tried to use native API for Optuna, it would fail some other way.

@hcho3
Copy link
Collaborator

hcho3 commented Dec 5, 2020

That's right, until #6323 is resolved.

@pseudotensor
Copy link
Contributor Author

Is the Optuna calback code complicated? I'll have to check it out.

@trivialfis
Copy link
Member

I will submit a PR on optuna next week. We haven't done any test on using dask interface with optuna.

@pseudotensor
Copy link
Contributor Author

pseudotensor commented Dec 5, 2020

Awesome, thanks @trivialfis !

I suppose no changes are required for the dask-optuna package https://github.com/jrbourbeau/dask-optuna

@pseudotensor pseudotensor changed the title dask: TypeError: fit() got an unexpected keyword argument 'callbacks' dask scikit-learn API: TypeError: fit() got an unexpected keyword argument 'callbacks' Dec 5, 2020
@trivialfis
Copy link
Member

Closed by #6471

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants