View source: R/Predict_naiveBayes.R
| Predict_naiveBayes | R Documentation |
Predict classification with naive Bayes model.
Predict_naiveBayes(Data, Model, ...)
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 |
... |
|
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.
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 |
Michael Thrun
Train_naiveBayes
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.