gen_bn_elicit: Generate synthetic data using BN parameter learning with an...

Description Usage Arguments Value Examples

View source: R/gen_bn.R

Description

gen_bn_elicit uses Bayesian parameter learning (Maximum Likelihood Estimation, MLE) to learn the values of the parameters based on the given dependencies of the variables and the input data.

Usage

1
gen_bn_elicit(training_set, bn_structure, evidences = NA)

Arguments

training_set

A data frame of the training data. The generated data will have the same size as the training_set.

bn_structure

A string of the relationships between variables from modelstring.

evidences

A string of evidence that is used to constraint the sampling of the generated data.

Value

The output is a list of three objects: i) structure: the structure of the BN indicating the relationship between the variables (a bn-class object); ii) fit_model: the fitted model showing the parameter distributions between the variables ((a bn.fit) object and iii) gen_data: the generated synthetic data - if there is evidence to constraint the values for some of the variables, the generated synthetic data will be sampled accroding to the criteria.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
adult_data <- split_data(adult[1:100,], 70)
bn_evidence <- "age >=18 & capital_gain>=0 & capital_loss >=0 &
               hours_per_week>=0 & hours_per_week<=100"
bn_structure <- "[native_country][income][age|marital_status:education]"
bn_structure = paste0(bn_structure, "[sex][race|native_country][marital_status|race:sex]")
bn_structure = paste0(bn_structure,"[relationship|marital_status][education|sex:race]")
bn_structure = paste0(bn_structure,"[occupation|education][workclass|occupation]")
bn_structure = paste0(bn_structure,"[hours_per_week|occupation:workclass]")
bn_structure = paste0(bn_structure,"[capital_gain|occupation:workclass:income]")
bn_structure = paste0(bn_structure,"[capital_loss|occupation:workclass:income]")
bn_elicit <- gen_bn_elicit(adult_data$training_set, bn_structure, bn_evidence)

sdglinkage documentation built on April 27, 2020, 5:09 p.m.