-
Notifications
You must be signed in to change notification settings - Fork 705
[design doc] XGBoost on SQLFlow #753
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
Merged
Yancey0623
merged 25 commits into
sql-machine-learning:develop
from
Yancey0623:xgboost_design
Sep 5, 2019
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
d8fe348
rename antxgboost design
Yancey0623 999c673
add xgboost design
Yancey0623 eb17739
update
Yancey0623 c30485a
update
Yancey0623 ba274b1
update doc
Yancey0623 320c3be
polish doc
Yancey0623 e359497
initialize xgboost codegen
Yancey0623 50e7031
initialize xgboost codegen
Yancey0623 fe66c3d
Merge branch 'develop' of https://github.com/sql-machine-learning/sql…
Yancey0623 e83530b
init xgboost codegen
Yancey0623 545645e
fix typo
Yancey0623 d097b4f
Merge branch 'develop' of https://github.com/sql-machine-learning/sql…
Yancey0623 7861959
update
Yancey0623 9238117
model to params
Yancey0623 4d4f867
remove conflict file
Yancey0623 0b1d9a3
remove unused code
Yancey0623 005b754
Update xgboost_on_sqlflow_design.md
wangkuiyi 60ca030
remove xgb resolver
Yancey0623 bb62e19
Merge branch 'xgboost_design' of github.com:Yancey1989/sqlflow into x…
Yancey0623 f71b5c3
update
Yancey0623 f9e237b
Merge branch 'develop' of https://github.com/sql-machine-learning/sql…
Yancey0623 bce4a2d
fix conflict
Yancey0623 1366fee
remove some details section
Yancey0623 bdd68be
update follows the comment
Yancey0623 3583dd4
Merge branch 'develop' into xgboost_design
Yancey0623 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,45 @@ | ||
| # Design Doc: XGBoost on SQLFlow | ||
|
|
||
| ## Introduction | ||
|
|
||
| This design explains how SQLFlow calls [XGBoost](https://xgboost.ai/) for training models and prediciton. | ||
|
|
||
| ## Usage | ||
|
|
||
| To explain the benefit of integrating XGBoost with SQLFlow, let us start with an example. The following SQLFlow code snippet shows how users can train an XGBoost tree model named `my_xgb_model`. | ||
|
|
||
| ``` sql | ||
| SELECT * FROM train_table | ||
| TRAIN xgboost.multi.softmax | ||
| WITH | ||
| train.num_round=2, | ||
| max_depth=2, | ||
| eta=1 | ||
| LABEL class | ||
| INTO my_xgb_model; | ||
| ``` | ||
|
|
||
| The following example shows how to predict using the model `my_xgb_model`. | ||
|
|
||
| ``` sql | ||
| SELECT * FROM test_table | ||
| PREDICT pred_table.result | ||
| USING my_xgb_model; | ||
| ``` | ||
|
|
||
| The the above examples, | ||
| - `my_xgb_model` names the trained model. | ||
| - `xgboost.multi.softmax` is the model spec, where | ||
| - the prefix `xgboost.` tells the model is a XGBoost one, but not a Tensorflow model, and | ||
| - `multi.softmax` names an [XGBoost learning task](https://xgboost.readthedocs.io/en/latest/parameter.html#learning-task-parameters). | ||
| - In the `WITH` clause, | ||
| - keys with the prefix `train.` identifies parameters of XGBoost API [`xgboost.train`](https://xgboost.readthedocs.io/en/latest/python/python_api.html#xgboost.train), and | ||
| - keys without any prefix identifies [XGBoost Parameters](https://xgboost.readthedocs.io/en/latest/parameter.html) except the `objective` parameter, which was specified by the identifier after the keyword `TRAIN`, as explained above. | ||
|
|
||
| ## The Code Generator | ||
|
|
||
| The code generator `codegen_xgboost.go` outputs an XGBoost program in Python. It contains the following features: | ||
| 1. It tells the SQL engine to run the SELECT statement and retrieve the training/test data. It saves the data into a text file, which could be loaded by XGBoost using the DMatrix interface. | ||
| 1. Parse and resolve the WITH clause to fill the `xgboost.train` arguments and the XGBoost Parameters. | ||
| 1. Save the trained model on disk. | ||
| 1. For the PREDICT clause, it loads the trained model and test data and then outputs the prediction result to a SQL engine. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the parsing of the WITH clause is the parser's work, but not the submitter's work, am I right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parser can parse the WITH clause to a general attrs struct which is a Go struct
map[string]*expr, and each generator would resolve theattrsto program parameters, such as XGBoost generator would convert the attrs as follows:train.prefix toxgboost.trainarguments.