PREDICT_NAIVE_BAYES
Applies a Naive Bayes model on an input relation.
Depending on how the type
parameter is set, PREDICT_NAIVE_BAYES returns a VARCHAR that specifies either the predicted class or probability of the predicted class. If the function returns probability, you can cast the return value to an INTEGER or another numeric data type.
Syntax
PREDICT_NAIVE_BAYES ( input‑columns USING PARAMETERS model_name = 'model‑name' [, type = ' return‑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. |
Parameters
model_name
|
Name of the model (case-insensitive). |
type
|
One of the following:
|
class
|
Required if |
match_by_pos
|
Boolean value that specifies how input columns are matched to model features:
|
Examples
=> 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)