Learn R Programming

PDEnaiveBayes (version 0.2.8)

ApplyBayesTheorem4Likelihoods: ApplyBayesTheorem4Likelihoods

Description

Calculates the posteriors, for given likelihoods and priors using the Bayes Theorem

Usage

ApplyBayesTheorem4Likelihoods(Likelihoods,Priors,threshold=.Machine$double.eps*1000)

Value

Posteriors

[1:n, 1:d] Numeric matrix with posterior probability according to the bayes theorem.

Arguments

Likelihoods

List of d numeric matrices, one per feature, each matrix with 1:k columns containing the distribution of class 1:k.

Priors

[1:k] Numeric vector with prior probability for each class.

threshold

(Optional: Default=0.00001).

Author

Michael Thrun

Examples

Run this code
if(requireNamespace("FCPS")){
  data(Hepta)
  Data=Hepta$Data
  Cls=Hepta$Cls
  #parametric
  #V=Train_naiveBayes(Data,Cls,Gaussian=TRUE)
  #ClsTrain=V$ClsTrain
  #table(Cls,ClsTrain)
  
  #non-parametric
  V=Train_naiveBayes(Data,Cls,Gaussian=FALSE)
  ClsTrain=V$ClsTrain
  table(Cls,ClsTrain)
}

Run the code above in your browser using DataLab