PREDICT_NAIVE_BAYES
Applies a Naive Bayes model on an input table or view.
Important: Before using a machine learning function, be aware that all the ongoing transactions might be committed.
Syntax
PREDICT_NAIVE_BAYES ( predictor_columns USING PARAMETERS model_name = 'model_name' [, type = ' { RESPONSE | PROBABILITY } ',] [class = 'user_input_class', ] [match_by_pos = 'method'] )
Arguments
predictor_columns |
A comma-separated list of the columns in Supports the use of wildcard (*) characters in place of column names. |
Parameters
model_name = 'model_name' |
The name of the model. Model names are case insensitive. |
type = '{ RESPONSE | PROBABILITY }' |
(Optional) Specifies that the function can take the value Default Value: response |
class = 'user_input_class' |
(Optional) Specifies a specific class to use when |
match_by_pos= 'method' |
(Optional) Valid Values:
|
Return
Return data type: VARCHAR |
Returns the predicted class or the probability of the predicted class, depending on the response input. The return can be cast to INT or other numeric types when the return is in the probability of the predicted class. |
Examples
This example shows how you can use the PREDICT_NAIVE_BAYES function.
=> SELECT party, PREDICT_NAIVE_BAYES (vote1, vote2, vote3 USING PARAMETERS model_name = 'naive_house84_model', type = 'response') AS Predicted_Party FROM house84_test; party | Predicted_Party ------------+----------------- democrat | democrat democrat | democrat democrat | democrat republican | republican democrat | democrat democrat | democrat democrat | democrat democrat | democrat democrat | democrat republican | republican democrat | democrat democrat | democrat democrat | democrat democrat | republican republican | republican democrat | democrat republican | republican . . . (99 rows)