bayesProbabilitySimple: Assign a probability using a simple (network) Bayesian...

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/bayesSimple.R

Description

Uses simple Bayesian inference to return the probability or relative likelihood or a discrete label or continuous value.

Usage

1
2
3
4
5
6
7
8
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 c(). Vector of strings that are the names of the features the to-predict label depends on. If an empty vector is given, then all of the features are used (except for the label). The order then depends on the features' order.

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

\insertRef

rpkg:bnlearn_4.5mmb

See Also

mmb::bayesInferSimple()

Examples

1
2
3
4
5
6
7
8
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)

mmb documentation built on Oct. 23, 2020, 5:21 p.m.