NAIVE_BAYES
Executes the Naive Bayes algorithm on an input table or view. The result is a Naive Bayes model.
The following explains how columns are treated based on their data type:
- FLOAT - Values are assumed to follow some Gaussian distribution.
- INTEGER - Values are assumed to belong to one multinomial distribution.
- CHAR/VARCHAR - Values are assumed to follow some categorical distribution.
- BOOLEAN - Values are treated as categorical with two values.
Important: Before using a machine learning function, be aware that all the ongoing transactions might be committed.
Syntax
NAIVE_BAYES ( 'model_name', 'input_relation', 'response_column', 'predictor_col1, predictor_col2, ..., predictor_coln' [ USING PARAMETERS[exclude_columns='col1, col2, ..., coln',] [alpha=value] ])
Arguments
model_name |
The name of the model. Model names are case insensitive. |
input_relation |
The table or view that contains the training data for building the model. |
response_column |
The name of the column in the This column must be discrete labels that represent different class labels. |
predictor_columns |
A comma-separated list of the columns in the Supported Data Types: INT, CHAR/VARCHAR, FLOAT, BOOLEAN Supports the use of wildcard (*) characters in place of column names. If you use a wildcard character (*) in place of a column name, the function selects all the columns in |
Parameters
exclude_columns=col1, col2, ..., coln |
(Optional) The columns from |
alpha=value |
(Optional) The parameter used to control Laplace smoothing. Specifies use of Laplace smoothing if the event model is categorical, multinomial, or Bernoulli. Default Value: 1.0 |
Privileges
To use NAIVE_BAYES, you must either be a superuser or have CREATE privileges for the schema of the output view and SELECT privileges for the input table or view. There are no privileges needed on the function itself.
See GRANT (Schema) and GRANT (Table).
Examples
This example shows how you can use the NAIVE_BAYES function.
=> SELECT NAIVE_BAYES('naive_house84_model', 'house84_train', 'party', '*' USING PARAMETERS exclude_columns='party, id'); NAIVE_BAYES -------------------------------------------------- Finished. Accepted Rows: 324 Rejected Rows: 0 (1 row)