bayesProbabilitySimple {mmb} | R Documentation |
Assign a probability using a simple (network) Bayesian classifier.
Description
Uses simple Bayesian inference to return the probability or relative likelihood or a discrete label or continuous value.
Usage
bayesProbabilitySimple(
df,
features,
targetCol,
selectedFeatureNames = c(),
retainMinValues = 1,
doEcdf = FALSE
)
Arguments
df |
data.frame |
features |
data.frame with bayes-features. One of the features needs to be the label-column. |
targetCol |
string with the name of the feature that represents the label. |
selectedFeatureNames |
vector default |
retainMinValues |
integer to require a minimum amount of data points when segmenting the data feature by feature. |
doEcdf |
default FALSE a boolean to indicate whether to use the empirical CDF to return a probability when inferencing a continuous feature. If false, uses the empirical PDF to return the rel. likelihood. |
Value
double the probability of the target-label, using the maximum a posteriori estimate.
Author(s)
Sebastian Hönel sebastian.honel@lnu.se
References
Scutari M (2010). “Learning Bayesian Networks with the bnlearn R Package.” Journal of Statistical Software, 35(3), 1–22. doi: 10.18637/jss.v035.i03.
See Also
mmb::bayesInferSimple()
Examples
feat1 <- mmb::createFeatureForBayes(
name = "Sepal.Length", value = mean(iris$Sepal.Length))
feat2 <- mmb::createFeatureForBayes(
name = "Sepal.Width", value = mean(iris$Sepal.Width), isLabel = TRUE)
# Assign a probability to a continuous variable (also works with nominal):
mmb::bayesProbabilitySimple(df = iris, features = rbind(feat1, feat2),
targetCol = feat2$name, retainMinValues = 5, doEcdf = TRUE)