PREDICT_RF_CLASSIFIER
Applies a random forest model on an input relation. The predicted class is selected only based on the popular vote of the decision trees in the forest. Therefore, in special cases the calculated probability of the predicted class may not be the highest.
Syntax
PREDICT_RF_CLASSIFIER ( input‑columns USING PARAMETERS model_name='model‑name' [, type='prediction‑type'] [, class='user‑input‑class'] [, match_by_pos=match‑by‑position] )
Arguments
input‑columns | Comma-separated list of columns to use from the input relation, or asterisk (*) to select all columns. |
Parameter Settings
Parameter name | Set to… |
---|---|
model_name
|
Name of the model (case-insensitive) |
type
|
Type of prediction to return, one of the following:
|
class
|
Class to use when the type parameter is set to Default: Auto |
match_by_pos
|
Boolean value that specifies how input columns are matched to model features:
|
Returns
VARCHAR data type that specifies one of the following, as determined by how the type
parameter is set:
- The predicted class (based on popular votes)
- Probability of a class for each input instance.
Examples
=> SELECT PREDICT_RF_CLASSIFIER (Sepal_Length, Sepal_Width, Petal_Length, Petal_Width USING PARAMETERS model_name='myRFModel') FROM iris; PREDICT_RF_CLASSIFIER ----------------------- setosa setosa setosa … versicolor versicolor versicolor … virginica virginica virginica … (150 rows)
This example shows how you can use the PREDICT_RF_CLASSIFIER function, using the match_by_pos
parameter:
=> SELECT PREDICT_RF_CLASSIFIER (Sepal_Length, Sepal_Width, Petal_Length, Petal_Width USING PARAMETERS model_name='myRFModel', match_by_pos='true') FROM iris; PREDICT_RF_CLASSIFIER ----------------------- setosa setosa setosa … versicolor versicolor versicolor … virginica virginica virginica … (150 rows)