-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [dask] add tutorial documentation (fixes #3814, fixes #3838) * add notes on saving the model * quick start examples * add examples * fix timeouts in examples * remove notebook * fill out prediction section * table of contents * add line back * linting * isort * Apply suggestions from code review Co-authored-by: Nikita Titov <[email protected]> * Apply suggestions from code review Co-authored-by: Nikita Titov <[email protected]> * move examples under python-guide * remove unused pickle import Co-authored-by: Nikita Titov <[email protected]>
- Loading branch information
1 parent
296397d
commit 15853a7
Showing
10 changed files
with
519 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Dask Examples | ||
============= | ||
|
||
This directory contains examples of machine learning workflows with LightGBM and [Dask](https://dask.org/). | ||
|
||
Before running this code, see [the installation instructions for the Dask-package](https://github.com/microsoft/LightGBM/tree/master/python-package#install-dask-package). | ||
|
||
After installing the package and its dependencies, any of the examples here can be run with a command like this: | ||
|
||
```shell | ||
python binary-classification.py | ||
``` | ||
|
||
The examples listed below contain minimal code showing how to train LightGBM models using Dask. | ||
|
||
**Training** | ||
|
||
* [binary-classification.py](./binary-classification.py) | ||
* [multiclass-classification.py](./multiclass-classification.py) | ||
* [ranking.py](./ranking.py) | ||
* [regression.py](./regression.py) | ||
|
||
**Prediction** | ||
|
||
* [prediction.py](./prediction.py) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import dask.array as da | ||
from distributed import Client, LocalCluster | ||
from sklearn.datasets import make_blobs | ||
|
||
import lightgbm as lgb | ||
|
||
if __name__ == "__main__": | ||
|
||
print("loading data") | ||
|
||
X, y = make_blobs(n_samples=1000, n_features=50, centers=2) | ||
|
||
print("initializing a Dask cluster") | ||
|
||
cluster = LocalCluster() | ||
client = Client(cluster) | ||
|
||
print("created a Dask LocalCluster") | ||
|
||
print("distributing training data on the Dask cluster") | ||
|
||
dX = da.from_array(X, chunks=(100, 50)) | ||
dy = da.from_array(y, chunks=(100,)) | ||
|
||
print("beginning training") | ||
|
||
dask_model = lgb.DaskLGBMClassifier(n_estimators=10) | ||
dask_model.fit(dX, dy) | ||
assert dask_model.fitted_ | ||
|
||
print("done training") |
Oops, something went wrong.