Generating data from a network

<< Click to Display Table of Contents >>

Navigation:  Using SMILE > Datasets >

Generating data from a network

Given that a Bayesian network is a representation of the joint probability distribution over its variables, we can generate a data set based on this distribution using the DSL_dataGenerator class. The DSL_dataGenerator::GenerateData method has three overloads, which write the data to the following outputs:

DSL_dataset object

a text file specified by a file name

any object derived from the pure abstract class DSL_dataGeneratorOutput

The following code snippet generates 200 records with 1/4 of the values marked as missing and writes the output to a text file "out.txt":

DSL_network net;

// create or load network here

DSL_dataGenerator gen(net);

gen.SetNumberOfRecords(200);

gen.SetMissingValuePercent(25);

gen.GenerateData("out.txt");