PREDICT_RF_CLASSIFIER
Applies a random forest model on an input table or view. 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.
Important: Before using a machine learning function, be aware that all the ongoing transactions might be committed.
Syntax
PREDICT_RF_CLASSIFIER ( col1, col2, ... coln USING PARAMETERS model_name = 'name_of_model' [, type= ' { RESPONSE | PROBABILITY } ',] [class= 'user_input_class',] [match_by_pos = 'method'])
Arguments
col1, col2, ..., coln |
The columns to use from the input table or view. |
Parameters
model_name = 'name_of_model' |
The name of the random forest model. Model names are case-insensitive. |
type = 'method' |
(Optional) Determines the type of prediction for random forest. When Valid Values
|
class = 'user_input_class' |
(Optional) Specifies a specific class to use when type is set to PROBABILITY. The predict function returns the probability of the specified class to be the response. If class is not specified, its default value is the predicted class -- the one with popular vote. Thus, the predict function returns the probability that the input instance belonging to its predicted class. Default Value: Auto |
match_by_pos= 'method' |
(Optional) Valid Values:
|
Return
Return data type: VARCHAR |
The predict function returns the predicted class (based on popular votes) or probability of a class (depending on the value of the optional input parameters type and class) for each input instance. |
Examples
This example shows how you can use the PREDICT_RF_CLASSIFIER function.
=> 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_Wdith 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)