myNaiveBayes: Naive bayes classifier with discretization and Gaussian...

Description Usage Arguments Details Value Examples

View source: R/nb.R

Description

We assume that the data follows Gaussian Distribution with small sample size.Continuous Xi we estimated with Guassian Distribution.For categorical and logical Xi, P(Xi|Y) would be calculated with laplace smoothing.all needed info to do bayes inference from train data will be in the object.

Usage

1
myNaiveBayes(x,y,laplace = 0,discre = FALSE,alpha=0.05)

Arguments

x

A dataframe of train data

y

A dataframe or vector of categorical labels

laplace

parametre for laplace smoothing, default is 0

discre

paramtre to decide discretization, default is FALSE

alpha

Significance level value for discretization, default is 0.05

Details

This would give us a 'NB' class object for predicting and printing.To estimate the parameters for a feature's distribution, one must assume a distribution or generate nonparametric models for the features from the training set.If you are dealing with continuous data, a common assumption is that these continuous values are Gaussians. For attributes with missing values, the corresponding table entries are omitted for prediction.

Value

object for Naive bayes classifier

Examples

1
2
3
4
5
x=iris[c(1:40,51:90,101:140),-5]
y=iris[c(1:40,51:90,101:140),5]
testx = iris[c(41:50,91:100,141:150),-5]
m2 = myNaiveBayes(x,y)
m2

sharechanxd/myNBpackage documentation built on Dec. 23, 2021, 1:21 a.m.