public static void main(String[] args) throws Exception { //We can load a Bayesian network using the static class BayesianNetworkLoader BayesianNetwork bn = BayesianNetworkLoader.loadFromFile("./networks/simulated/WasteIncinerator.bn"); //Now we print the loaded model System.out.println(bn.toString()); //Now we change the parameters of the model bn.randomInitialization(new Random(0)); //We can save this Bayesian network to using the static class BayesianNetworkWriter BayesianNetworkWriter.save(bn, "networks/simulated/tmp.bn"); } }
BayesianNetworkWriter.save(amidstBN, fullAmidstFileName);
public static void main(String[] args) throws ExceptionHugin, IOException { //Load the datastream String filename = "datasets/simulated/cajamar.arff"; DataStream<DataInstance> data = DataStreamLoader.open(filename); //Learn the model Model model = new FactorAnalysis(data.getAttributes()); // ((MixtureOfFactorAnalysers)model).setNumberOfLatentVariables(3); model.updateModel(data); BayesianNetwork bn = model.getModel(); System.out.println(bn); // Save with .bn format BayesianNetworkWriter.save(bn, "networks/simulated/exampleBN.bn"); // Save with hugin format //BayesianNetworkWriterToHugin.save(bn, "networks/simulated/exampleBN.net"); }
public static void main(String[] args) throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataFlink<DataInstance> dataFlink = DataFlinkLoader.loadDataFromFile(env, "./data.arff", false); DAG dag = SetBNwithHidden.getHiddenNaiveBayesStructure(dataFlink); BayesianNetwork bnet = new BayesianNetwork(dag); System.out.println("\n Number of variables \n " + bnet.getDAG().getVariables().getNumberOfVars()); System.out.println(dag.toString()); BayesianNetworkWriter.save(bnet, "./BNHiddenExample.bn"); }
public static void main(String[] args) throws IOException { //Load the datastream String filename = "datasets/simulated/docs.nips.small.arff"; DataStream<DataInstance> data = DataStreamLoader.open(filename); //Learn the model Model model = new LDA(data.getAttributes()); model.updateModel(data); BayesianNetwork bn = model.getModel(); //System.out.println(bn); // Save with .bn format BayesianNetworkWriter.save(bn, "networks/simulated/exampleBN.bn"); }
public static void main(String[] args) throws IOException, ExceptionHugin { //Set-up Flink session. // Configuration conf = new Configuration(); // conf.setInteger("taskmanager.network.numberOfBuffers", 12000); final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); //env.getConfig().disableSysoutLogging(); // env.setParallelism(Main.PARALLELISM); //Load the datastream String filename = "datasets/simulated/cajamarDistributed.arff"; DataFlink<DataInstance> data = DataFlinkLoader.open(env, filename, false); //Learn the model Model model = new FactorAnalysis(data.getAttributes()); model.updateModel(data); BayesianNetwork bn = model.getModel(); System.out.println(bn); // Save with .bn format BayesianNetworkWriter.save(bn, "networks/simulated/exampleBN.bn"); // Save with hugin format //BayesianNetworkWriterToHugin.save(bn, "networks/simulated/exampleBN.net"); }
System.out.println(svb.getLearntBayesianNetwork().toString()); BayesianNetworkWriter.save(svb.getLearntBayesianNetwork(),pathNetwork);
public static void main(String[] args) throws IOException { //Set-up Flink session. Configuration conf = new Configuration(); conf.setInteger("taskmanager.network.numberOfBuffers", 12000); final ExecutionEnvironment env = ExecutionEnvironment.createLocalEnvironment(conf); env.getConfig().disableSysoutLogging(); env.setParallelism(Main.PARALLELISM); //Load the data String filename = "datasets/simulated/docs.nips.distributed.arff"; DataFlink<DataInstance> data = DataFlinkLoader.loadDataFromFolder(env, filename, false); //Learn the model Model model = new LDA(data.getAttributes()); model.updateModel(data); BayesianNetwork bn = model.getModel(); //System.out.println(bn); // Save with .bn format BayesianNetworkWriter.save(bn, "networks/simulated/exampleBN.bn"); }
System.out.println(svb.getLearntBayesianNetwork().toString()); BayesianNetworkWriter.save(svb.getLearntBayesianNetwork(),pathNetwork);
public static void main(String[] args) throws Exception { //Load the learnt model BayesianNetwork fireDetector = BayesianNetworkLoader.loadFromFile("./models/LearntFireDetectorModel.bn"); //Access the variable of interest. Variable fire = fireDetector.getVariables().getVariableByName("Fire"); Variable temperature = fireDetector.getVariables().getVariableByName("Temperature"); Variable smoke = fireDetector.getVariables().getVariableByName("Smoke"); //Modify the parameters of the model according to our prior knowledge. Multinomial fireprob = fireDetector.getConditionalDistribution(fire); fireprob.setProbabilities(new double[]{0.999, 0.001}); Normal_MultinomialParents tempprob = fireDetector.getConditionalDistribution(temperature); tempprob.getNormal(1).setMean(tempprob.getNormal(0).getMean()+10); tempprob.getNormal(1).setVariance(tempprob.getNormal(0).getVariance()); Multinomial_MultinomialParents smokeProb = fireDetector.getConditionalDistribution(smoke); smokeProb.getMultinomial(1).setProbabilities(new double[]{0.001, 0.999}); //Print the model System.out.println(fireDetector); //Save to disk the new model BayesianNetworkWriter.save(fireDetector,"./models/FireDetectorModel.bn"); } }
BayesianNetworkWriter.save(bn, "networks/simulated/BNHiddenExample.bn");
BayesianNetworkWriter.save(bn, "networks/simulated/BNExample.bn");
BayesianNetworkWriter.save(fireDectector,"./models/LearntFireDetectorModel.bn");