Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions sql/codegen_xgboost.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,29 +522,29 @@ func xgParseColumns(pr *extendedSelect, filler *xgboostFiller) error {

func xgParseEstimator(pr *extendedSelect, filler *xgboostFiller) error {
switch strings.ToUpper(pr.estimator) {
case "XGBOOSTESTIMATOR":
case "XGBOOST.ESTIMATOR":
if len(filler.Objective) == 0 {
return xgParseEstimatorError(pr.estimator, fmt.Errorf("objective must be defined"))
}
case "XGBOOSTCLASSIFIER":
case "XGBOOST.CLASSIFIER":
if obj := filler.Objective; len(obj) == 0 {
filler.Objective = "binary:logistic"
} else if !strings.HasPrefix(obj, "binary") && !strings.HasPrefix(obj, "multi") {
return xgParseEstimatorError(pr.estimator, fmt.Errorf("found non classification objective(%s)", obj))
}
case "XGBOOSTBINARYCLASSIFIER":
case "XGBOOST.BINARYCLASSIFIER":
if obj := filler.Objective; len(obj) == 0 {
filler.Objective = "binary:logistic"
} else if !strings.HasPrefix(obj, "binary") {
return xgParseEstimatorError(pr.estimator, fmt.Errorf("found non binary objective(%s)", obj))
}
case "XGBOOSTMULTICLASSIFIER":
case "XGBOOST.MULTICLASSIFIER":
if obj := filler.Objective; len(obj) == 0 {
filler.Objective = "multi:softmax"
} else if !strings.HasPrefix(obj, "multi") {
return xgParseEstimatorError(pr.estimator, fmt.Errorf("found non multi-class objective(%s)", obj))
}
case "XGBOOSTREGRESSOR":
case "XGBOOST.REGRESSOR":
if obj := filler.Objective; len(obj) == 0 {
filler.Objective = "reg:squarederror"
} else if !strings.HasPrefix(obj, "reg") && !strings.HasPrefix(obj, "rank") {
Expand Down
8 changes: 4 additions & 4 deletions sql/codegen_xgboost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
testXGTrainSelectIris = `
SELECT *
FROM iris.train
TRAIN XGBoostEstimator
TRAIN xgboost.Estimator
WITH
train.objective = "multi:softmax",
train.num_class = 3,
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestXGBoostAttr(t *testing.T) {

trainClause := `
SELECT a, b, c, d, e FROM table_xx
TRAIN XGBoostEstimator
TRAIN xgboost.Estimator
WITH
train.objective = "binary:logistic",
train.booster = gblinear,
Expand Down Expand Up @@ -202,7 +202,7 @@ func TestColumnClause(t *testing.T) {
parser := newParser()
sqlHead := `
SELECT a, b, c, d, e FROM table_xx
TRAIN XGBoostEstimator
TRAIN xgboost.Estimator
WITH attr_x = XXX
`
sqlTail := `
Expand Down Expand Up @@ -311,7 +311,7 @@ func TestXGBoostFiller(t *testing.T) {
parser := newParser()
trainClause := `
SELECT * FROM iris.train
TRAIN XGBoostRegressor
TRAIN xgboost.Regressor
WITH
train.max_depth = 5,
train.eta = 0.03,
Expand Down
8 changes: 4 additions & 4 deletions sql/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ func train(wr *PipeWriter, tr *extendedSelect, db *DB, cwd string, modelDir stri
}

var program bytes.Buffer
// FIXME(sperlingxx): write a separate train pipeline for xgboost to support remote mode
if os.Getenv("SQLFLOW_submitter") == "XGBOOST" {
if strings.HasPrefix(strings.ToUpper(tr.estimator), `XGBOOST.`) {
// FIXME(sperlingxx): write a separate train pipeline for xgboost to support remote mode
filler, e := newXGBoostFiller(tr, fts, db)
if e != nil {
return fmt.Errorf("genXG %v", e)
Expand Down Expand Up @@ -419,8 +419,8 @@ func pred(wr *PipeWriter, pr *extendedSelect, db *DB, cwd string, modelDir strin
}

var buf bytes.Buffer
// FIXME(sperlingxx): write a separate pred pipeline for xgboost to support remote mode
if os.Getenv("SQLFLOW_submitter") == "XGBOOST" {
if strings.HasPrefix(strings.ToUpper(tr.estimator), `XGBOOST.`) {
// FIXME(sperlingxx): write a separate pred pipeline for xgboost to support remote mode
filler, e := newXGBoostFiller(pr, fts, db)
if e != nil {
return fmt.Errorf("genXG %v", e)
Expand Down
3 changes: 0 additions & 3 deletions sql/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ func TestExecutorTrainAndPredictXGBoost(t *testing.T) {
modelDir, e := ioutil.TempDir("/tmp", "sqlflow_models")
a.Nil(e)
defer os.RemoveAll(modelDir)
defer os.Unsetenv("SQLFLOW_submitter")
e = os.Setenv("SQLFLOW_submitter", "XGBOOST")
a.NoError(e)
a.NotPanics(func() {
stream := runExtendedSQL(testXGTrainSelectIris, testDB, modelDir, nil)
a.True(goodStream(stream.ReadAll()))
Expand Down