Computes the probability (discrete feature) or relative likelihood (continuous feature) of one given feature and a concrete value for it.

bayesComputeMarginalFactor(df, feature, doEcdf = FALSE)

Arguments

df

data.frame that contains all the feature's data

feature

data.frame containing the designated feature as created by @seealso mmb::createFeatureForBayes().

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. This parameter does not have any effect when inferring discrete values. Using the ECDF, a probability to find a value less than or equal to the given value is returned.

Value

numeric the probability or likelihood of the given feature assuming its given value.

Examples

feat <- mmb::createFeatureForBayes( name = "Petal.Length", value = mean(iris$Petal.Length)) mmb::bayesComputeMarginalFactor(df = iris, feature = feat)
#> [1] 0.1258313
mmb::bayesComputeMarginalFactor(df = iris, feature = feat, doEcdf = TRUE)
#> [1] 0.38