PREDICT_XGB_CLASSIFIER
Applies an XGBoost classifier model on an input relation. PREDICT_XGB_CLASSIFIER returns a VARCHAR data type that specifies one of the following, as determined by how the type parameter is set:
-
The predicted class (based on probability scores)
-
Probability of a class for each input instance.
Syntax
PREDICT_XGB_CLASSIFIER ( input-columns
USING PARAMETERS model_name = 'model-name'
[, type = 'prediction-type' ]
[, class = 'user-input-class' ]
[, match_by_pos = 'match-by-position' ]
[, probability_normalization = 'prob-normalization' ] )
Arguments
input-columns- Comma-separated list of columns to use from the input relation, or asterisk (*) to select all columns.
Parameters
model_nameName of the model (case-insensitive).
type- Type of prediction to return, one of the following:
-
response(default): The class with the highest probability among all possible classes. -
probability: Valid only if theclassparameter is set, returns for each input instance the probability of the specified class or predicted class.
-
class- Class to use when the
typeparameter is set toprobability. If you omit this parameter, the function uses the predicted class—the one with the highest probability score. Thus, the predict function returns the probability that the input instance belongs to the specified or predicted class. match_by_posBoolean value that specifies how input columns are matched to model features:
-
false(default): Match by name. -
true: Match by the position of columns in the input columns list.
-
probability_normalizationThe classifier's normalization method, either
softmax(multi-class classifier) orlogit(binary classifier). If unspecified, the defaultlogitfunction is used for normalization.
Examples
Use
PREDICT_XGB_CLASSIFIER to apply the classifier to the test data:
=> SELECT PREDICT_XGB_CLASSIFIER (Sepal_Length, Sepal_Width, Petal_Length, Petal_Width
USING PARAMETERS model_name='xgb_iris', probability_normalization='logit') FROM iris1;
PREDICT_XGB_CLASSIFIER
------------------------
setosa
setosa
setosa
.
.
.
versicolor
versicolor
versicolor
.
.
.
virginica
virginica
virginica
.
.
.
(90 rows)
See XGBoost for classification for more examples.