Predict_naiveBayes: Predict_naiveBayes

View source: R/Predict_naiveBayes.R

Predict_naiveBayesR Documentation

Predict_naiveBayes

Description

Predict classification with naive Bayes model.

Usage

Predict_naiveBayes(Data, Model, ...)

Arguments

Data

[1:n,1:d] matrix of test data. It consists of n cases of d-dimensional data points. Every case has d attributes, variables or features.

Model

Optional, list with elements Priors,c_2List_Train,Thetas, alternative set arguements seperatly

...

Priors: Optional, if Model missing, then [1:k] Numeric vector with prior probability for each class.

c_2List_Train: Optional, if Model missing, then c_2List_Train is the output of GetLikelihoods: a list of two three elements of Kernels, Likelihoods per feature and class, optional Thetas or PlausibleCenters depending on parameter setting

Thetas: Optional, if Model missing, then If c_2List_Train is missing, alternatively the parameters mean and standard deviation of the gaussian distributions per class and feaures.

PlotIt: Optional: Default=FALSE, TRUE: Plots Likelihoods

PlotCutOff: Optional: Scalar indicating how many features (starting from 1) should be plotted, or a numerical vector specifying the indices of the features to plot. Note: In the second case, avoid selecting too many features, as this may cause the plot to fail

Details

The function is implemented in a way so that one can combine training and test data although it is intended to be applied on test data only.

Value

Cls

[1:n] numerical vector with n numbers defining the classification. It has k unique numbers representing the arbitrary labels of the classification.

Posteriors

[1:n, 1:l] Numeric matrices with posterior probabilities.

DataLikelihoodsPerClass

list of length d, each element is a matrix [1:n,1:k] of interpolated class likelihoods per feature d

Author(s)

Michael Thrun

See Also

Train_naiveBayes

Examples

if(requireNamespace("FCPS")){
V=FCPS::ClusterChallenge("Hepta",1000)
Data=V$Hepta
Cls=V$Cls
ind=1:length(Cls)
indtrain=sample(ind,800)
indtest=setdiff(ind,indtrain)

#PDEbayes
model=Train_naiveBayes(Data[indtrain,],Cls[indtrain],Gaussian=FALSE)
ClsTrain=model$ClsTrain
table(Cls[indtrain],ClsTrain)

res=Predict_naiveBayes(Data[indtest,], Model = model)
table(Cls[indtest],res$ClsTest)
}

PDEnaiveBayes documentation built on Nov. 17, 2025, 5:07 p.m.