[doc] Include dask examples into doc. (#7530)
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
Dask
|
||||
====
|
||||
|
||||
This directory contains some demonstrations for using `dask` with `XGBoost`.
|
||||
For an overview, see
|
||||
https://xgboost.readthedocs.io/en/latest/tutorials/dask.html .
|
||||
5
demo/dask/README.rst
Normal file
5
demo/dask/README.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
XGBoost Dask Feature Walkthrough
|
||||
================================
|
||||
|
||||
This directory contains some demonstrations for using `dask` with `XGBoost`. For an
|
||||
overview, see :doc:`/tutorials/dask`
|
||||
@@ -1,3 +1,9 @@
|
||||
"""
|
||||
Example of training survival model with Dask on CPU
|
||||
===================================================
|
||||
|
||||
"""
|
||||
|
||||
import xgboost as xgb
|
||||
import os
|
||||
from xgboost.dask import DaskDMatrix
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
"""
|
||||
Example of training with Dask on CPU
|
||||
====================================
|
||||
|
||||
"""
|
||||
import xgboost as xgb
|
||||
from xgboost.dask import DaskDMatrix
|
||||
from dask.distributed import Client
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
"""Example of using callbacks in Dask"""
|
||||
"""
|
||||
Example of using callbacks with Dask
|
||||
====================================
|
||||
"""
|
||||
import numpy as np
|
||||
import xgboost as xgb
|
||||
from xgboost.dask import DaskDMatrix
|
||||
@@ -1,3 +1,7 @@
|
||||
"""
|
||||
Example of training with Dask on GPU
|
||||
====================================
|
||||
"""
|
||||
from dask_cuda import LocalCUDACluster
|
||||
from dask.distributed import Client
|
||||
from dask import array as da
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'''Dask interface demo:
|
||||
|
||||
Use scikit-learn regressor interface with CPU histogram tree method.'''
|
||||
"""
|
||||
Use scikit-learn regressor interface with CPU histogram tree method
|
||||
===================================================================
|
||||
"""
|
||||
from dask.distributed import Client
|
||||
from dask.distributed import LocalCluster
|
||||
from dask import array as da
|
||||
@@ -16,7 +17,7 @@ def main(client):
|
||||
y = da.random.random(m, partition_size)
|
||||
|
||||
regressor = xgboost.dask.DaskXGBRegressor(verbosity=1, n_estimators=2)
|
||||
regressor.set_params(tree_method='hist')
|
||||
regressor.set_params(tree_method="hist")
|
||||
# assigning client here is optional
|
||||
regressor.client = client
|
||||
|
||||
@@ -26,13 +27,13 @@ def main(client):
|
||||
bst = regressor.get_booster()
|
||||
history = regressor.evals_result()
|
||||
|
||||
print('Evaluation history:', history)
|
||||
print("Evaluation history:", history)
|
||||
# returned prediction is always a dask array.
|
||||
assert isinstance(prediction, da.Array)
|
||||
return bst # returning the trained model
|
||||
return bst # returning the trained model
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
# or use other clusters for scaling
|
||||
with LocalCluster(n_workers=4, threads_per_worker=1) as cluster:
|
||||
with Client(cluster) as client:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'''Dask interface demo:
|
||||
|
||||
Use scikit-learn regressor interface with GPU histogram tree method.'''
|
||||
"""
|
||||
Use scikit-learn regressor interface with GPU histogram tree method
|
||||
===================================================================
|
||||
"""
|
||||
|
||||
from dask.distributed import Client
|
||||
# It's recommended to use dask_cuda for GPU assignment
|
||||
|
||||
Reference in New Issue
Block a user