idaNb: Naive Bayes Classifier

idaNaiveBayesR Documentation

Naive Bayes Classifier

Description

This function generates a Naive Bayes classification model based on the contents of an IDA data frame (ida.data.frame).

Usage

idaNaiveBayes(form,data,id="id",modelname=NULL)

## S3 method for class 'idaNaiveBayes'
predict(object,newdata,id, withProbabilities=FALSE,...)
## S3 method for class 'idaNaiveBayes'
print(x,...)  

Arguments

form

A formula object that describes the model to fit.

data

An ida.data.frame object.

id

The name of the column that contains unique IDs.

modelname

Name for the model. Will be created automatically unless specified otherwise.

object

An object of the class idaNaiveBayes to used for prediction, i.e. for applying it to new data.

newdata

An IDA data frame that contains the data to which to apply the model.

withProbabilities

A boolean value indicating if the probabilities for each class value are included in the result of the predict function.

x

An object of the class idaNaiveBayes to be printed.

...

Additional parameters to pass to the print and predict method.

Details

idaNaiveBayes builds a Naive Bayes classification model, thus a model that assumes independence of input variables with respect to the target variable.

Continuous input variables are discretized using equal width discretization. Missing values are ignored on a record and attribute level when calculating the conditional probabilities.

Models are stored persistently in the database under the name modelname. Model names cannot have more than 64 characters and cannot contain white spaces. They need to be quoted like table names, otherwise they will be treated upper case by default. Only one model with a given name is allowed in the database at a time. If a model with modelname already exists, you need to drop it with idaDropModel first before you can create another one with the same name. The model name can be used to retrieve the model later (idaRetrieveModel).

Value

The function idaNaiveBayes returns an object of class "idaNaiveBayes" and "naiveBayes" compatible with Naive Bayes objects produced by the e1071 package.

The predict.idaNaiveBayes method applies the model to the data in a table and returns an IDA data frame that contains a list of tuples, each of which comprises one row ID and one prediction.

Examples

## Not run: 
#Create ida data frame
idf <- ida.data.frame("IRIS")

#Create a naive bayes model
nb <- idaNaiveBayes(Species~SepalLength,idf,"ID")

#Print the model
print(nb)

#Apply the model to data
idf2 <- predict(nb,idf,"ID")

#Inspect the results
head(idf2)


## End(Not run)

ibmdbR documentation built on Nov. 24, 2023, 5:09 p.m.