-
Notifications
You must be signed in to change notification settings - Fork 705
setup xgboost on sqlflow #662
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,35 @@ import ( | |
| "testing" | ||
| ) | ||
|
|
||
| const ( | ||
| testXGTrainSelectIris = ` | ||
| SELECT * | ||
| FROM iris.train | ||
| TRAIN XGBoostEstimator | ||
| WITH | ||
| objective = "multi:softmax", | ||
| num_class = 3, | ||
sperlingxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| max_depth = 5, | ||
| eta = 0.3, | ||
| tree_method = "approx", | ||
| num_round = 30 | ||
| COLUMN sepal_length, sepal_width, petal_length, petal_width | ||
| LABEL class INTO sqlflow_models.my_xgboost_model; | ||
| ` | ||
|
|
||
| testXGPredSelectIris = ` | ||
| SELECT * | ||
| FROM iris.test | ||
| PREDICT iris.predict | ||
| WITH | ||
| append_columns = [sepal_length, sepal_width, petal_length, petal_width], | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to avoid
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prob_column, detail_column, leaf_column and append_columns are optional. Only result_column is required for prediction task, which has a default column field: "result".
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can keep consistent with the TF example, specific result column in |
||
| prob_column = prob, | ||
| detail_column = detail, | ||
| encoding_column = encoding | ||
| USING sqlflow_models.my_xgboost_model; | ||
| ` | ||
| ) | ||
|
|
||
| func TestPartials(t *testing.T) { | ||
| a := assert.New(t) | ||
| tmpMap := make(map[string][]string) | ||
|
|
@@ -127,7 +156,7 @@ COLUMN a, b, c, d | |
| LABEL e INTO table_123; | ||
| ` | ||
| filler := parseAndFill(trainClause) | ||
| data, e := json.Marshal(filler.xgboostFields) | ||
| data, e := json.Marshal(filler.xgLearningFields) | ||
| a.NoError(e) | ||
| mapData := make(map[string]interface{}) | ||
| e = json.Unmarshal(data, &mapData) | ||
|
|
@@ -302,7 +331,7 @@ LABEL e INTO model_table; | |
| a.True(filler.IsTrain) | ||
| stdSlct := removeLastSemicolon(strings.Replace(filler.StandardSelect, "\n", " ", -1)) | ||
| a.EqualValues("SELECT * FROM iris.train", stdSlct) | ||
| a.EqualValues("model_table", filler.modelPath) | ||
| a.EqualValues("model_table", filler.ModelPath) | ||
|
|
||
| a.EqualValues("reg:squarederror", filler.Objective) | ||
| a.EqualValues(0.03, filler.Eta) | ||
|
|
@@ -328,15 +357,15 @@ LABEL e INTO model_table; | |
| a.EqualValues(&xgFeatureMeta{FeatureName: "petal_width", Dtype: "float32", InputShape: "[1]"}, filler.X[3]) | ||
|
|
||
| colFields := &xgColumnFields{} | ||
| e = json.Unmarshal([]byte(filler.xgColumnJSON), colFields) | ||
| e = json.Unmarshal([]byte(filler.ColumnJSON), colFields) | ||
| a.NoError(e) | ||
| a.EqualValues(filler.xgColumnFields, *colFields) | ||
| dsFields := &xgDataSourceFields{} | ||
| e = json.Unmarshal([]byte(filler.xgDataSourceJSON), dsFields) | ||
| e = json.Unmarshal([]byte(filler.DataSourceJSON), dsFields) | ||
| a.NoError(e) | ||
| a.EqualValues(filler.xgDataSourceFields, *dsFields) | ||
| xgbFields := &xgboostFields{} | ||
| e = json.Unmarshal([]byte(filler.xgboostJSON), xgbFields) | ||
| xgbFields := &xgLearningFields{} | ||
| e = json.Unmarshal([]byte(filler.LearningJSON), xgbFields) | ||
| a.NoError(e) | ||
| a.EqualValues(filler.xgboostFields, *xgbFields) | ||
| a.EqualValues(filler.xgLearningFields, *xgbFields) | ||
| } | ||
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.
What is the usage of the encoding column?
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.
Encoding column stores leaf indices of this sample in each tree. We transform leaf indices in a string which format like: "index_0,index_1,......,index_n"