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:

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 input_relation that represents the dependent variable, or outcome.

This column must be discrete labels that represent different class labels.

predictor_columns

A comma-separated list of the columns in the input_relation that represent the independent variables for the model.

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 input_relation. In this case, the response_column must be explicitly excluded, using the list assigned to exclude_columns.

Parameters

exclude_columns=col1, col2, ..., coln

(Optional) The columns from input_relation that you want to exclude from the predictor_columns argument.

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)

See Also