predict.NaiveBayes {hana.ml.r}R Documentation

Make Predictions from a "NaiveBayes" Object

Description

Similar to other predict methods, this function predicts fitted values from a fitted "NaiveBayes" object.

Usage

## S3 method for class 'NaiveBayes'
predict(model, data, key, features = NULL,
  alpha = NULL, verbose = NULL, thread.ratio = NULL)

Arguments

model

R6Class object
NaiveBayes object for prediction.

data

DataFrame
data for prediction.

key

character
Name of the ID column.

features

list of character, optional
Names of the feature columns. If features is not provided, it defaults to all non-ID columns.

alpha

double, optional
Laplace smoothing value. Set a positive value to enable Laplace smoothing for categorical variables and use that value as the smoothing parameter. Set value 0 to disable Laplace smoothing.
Defaults to the alpha value in the JSON model, if there is one, or 0 otherwise.

verbose

logical, optional
If true, output all classes and the corresponding confidences for each data point.
Defaults to False.

thread.ratio

double, optional
Controls the proportion of available threads to use. The value range is from 0 to 1, where 0 means only using 1 thread, and 1 means using at most all the currently available threads. Values outside this range tell PAL to heuristically determine the number of threads to use.
Defaults to 0.0.

Value

Predicted values are returned as a DataFrame, structured as follows.

Note

A non-zero Laplace value (alpha) is required if there exist discrete category values that only occur in the test set. It can be read from JSON models or from the parameter alpha in predict(). The Laplace value you set here takes precedence over the values read from JSON models.

See Also

hanaml.NaiveBayes

Examples

## Not run: 
Input DataFrame df2 for prediction:

> df2$collect()
ID HOMEOWNER MARITALSTATUS  ANNUALINCOME
0   0        NO       Married         120.0
1   1       YES       Married         180.0
2   2        NO        Single          90.0

Output:
> predict(model, df2, "ID", alpha=1.0, verbose=True)
ID CLASS  CONFIDENCE
0   0    NO   -6.572353
1   0   YES  -23.747252
2   1    NO   -7.602221
3   1   YES -169.133547
4   2    NO   -7.133599
5   2   YES   -4.648640

## End(Not run)

[Package hana.ml.r version 1.0.8 Index]