@Test public void test() throws Exception { CreatingBayesianNetworksWithLatentVariables.main(null); }
public static void main(String[] args) throws Exception { DataStream<DataInstance> data = DataStreamLoader.open("datasets/simulated/syntheticData.arff"); Variables variables = new Variables(data.getAttributes()); Variable a = variables.getVariableByName("A"); Variable b = variables.getVariableByName("B"); Variable c = variables.getVariableByName("C"); Variable d = variables.getVariableByName("D"); Variable e = variables.getVariableByName("E"); Variable g = variables.getVariableByName("G"); Variable h = variables.getVariableByName("H"); Variable i = variables.getVariableByName("I"); Variable hidden = variables.newMultinomialVariable("HiddenVar", Arrays.asList("TRUE", "FALSE")); DAG dag = new DAG(variables); dag.getParentSet(a).addParent(hidden); dag.getParentSet(b).addParent(hidden); dag.getParentSet(c).addParent(hidden); dag.getParentSet(d).addParent(hidden); dag.getParentSet(e).addParent(hidden); dag.getParentSet(g).addParent(hidden); dag.getParentSet(h).addParent(hidden); dag.getParentSet(i).addParent(hidden); System.out.println(dag.toString()); BayesianNetwork bn = new BayesianNetwork(dag); System.out.println(bn.toString()); BayesianNetworkWriter.save(bn, "networks/simulated/BNHiddenExample.bn"); }
CreatingBayesianNetworksWithLatentVariables { public static void main(String[] args) throws Exception { DataStream<DataInstance> data = DataStreamLoader.open("datasets/simulated/syntheticData.arff"); Variables variables = new Variables(data.getAttributes()); Variable a = variables.getVariableByName("A"); Variable b = variables.getVariableByName("B"); Variable c = variables.getVariableByName("C"); Variable d = variables.getVariableByName("D"); Variable e = variables.getVariableByName("E"); Variable g = variables.getVariableByName("G"); Variable h = variables.getVariableByName("H"); Variable i = variables.getVariableByName("I"); Variable hidden = variables.newMultinomialVariable("HiddenVar", Arrays.asList("TRUE", "FALSE")); DAG dag = new DAG(variables); dag.getParentSet(a).addParent(hidden); dag.getParentSet(b).addParent(hidden); dag.getParentSet(c).addParent(hidden); dag.getParentSet(d).addParent(hidden); dag.getParentSet(e).addParent(hidden); dag.getParentSet(g).addParent(hidden); dag.getParentSet(h).addParent(hidden); dag.getParentSet(i).addParent(hidden); System.out.println(dag.toString()); BayesianNetwork bn = new BayesianNetwork(dag); System.out.println(bn.toString()); BayesianNetworkWriter.save(bn, "networks/simulated/BNHiddenExample.bn"); } }
CreatingBayesianNetworksWithLatentVariables { public static void main(String[] args) throws Exception { DataStream<DataInstance> data = DataStreamLoader.open("datasets/simulated/syntheticData.arff"); Variables variables = new Variables(data.getAttributes()); Variable a = variables.getVariableByName("A"); Variable b = variables.getVariableByName("B"); Variable c = variables.getVariableByName("C"); Variable d = variables.getVariableByName("D"); Variable e = variables.getVariableByName("E"); Variable g = variables.getVariableByName("G"); Variable h = variables.getVariableByName("H"); Variable i = variables.getVariableByName("I"); Variable hidden = variables.newMultinomialVariable("HiddenVar", Arrays.asList("TRUE", "FALSE")); DAG dag = new DAG(variables); dag.getParentSet(a).addParent(hidden); dag.getParentSet(b).addParent(hidden); dag.getParentSet(c).addParent(hidden); dag.getParentSet(d).addParent(hidden); dag.getParentSet(e).addParent(hidden); dag.getParentSet(g).addParent(hidden); dag.getParentSet(h).addParent(hidden); dag.getParentSet(i).addParent(hidden); System.out.println(dag.toString()); BayesianNetwork bn = new BayesianNetwork(dag); System.out.println(bn.toString()); BayesianNetworkWriter.save(bn, "networks/simulated/BNHiddenExample.bn"); }  }
CreatingBayesianNetworksWithLatentVariables { public static void main(String[] args) throws Exception { DataStream<DataInstance> data = DataStreamLoader.open("datasets/simulated/syntheticData.arff"); Variables variables = new Variables(data.getAttributes()); Variable a = variables.getVariableByName("A"); Variable b = variables.getVariableByName("B"); Variable c = variables.getVariableByName("C"); Variable d = variables.getVariableByName("D"); Variable e = variables.getVariableByName("E"); Variable g = variables.getVariableByName("G"); Variable h = variables.getVariableByName("H"); Variable i = variables.getVariableByName("I"); Variable hidden = variables.newMultinomialVariable("HiddenVar", Arrays.asList("TRUE", "FALSE")); DAG dag = new DAG(variables); dag.getParentSet(a).addParent(hidden); dag.getParentSet(b).addParent(hidden); dag.getParentSet(c).addParent(hidden); dag.getParentSet(d).addParent(hidden); dag.getParentSet(e).addParent(hidden); dag.getParentSet(g).addParent(hidden); dag.getParentSet(h).addParent(hidden); dag.getParentSet(i).addParent(hidden); System.out.println(dag.toString()); BayesianNetwork bn = new BayesianNetwork(dag); System.out.println(bn.toString()); BayesianNetworkWriter.save(bn, "networks/simulated/BNHiddenExample.bn"); }  static void main(String[] args); }
CreatingBayesianNetworksWithLatentVariables { public static void main(String[] args) throws Exception { DataStream<DataInstance> data = DataStreamLoader.open("datasets/simulated/syntheticData.arff"); Variables variables = new Variables(data.getAttributes()); Variable a = variables.getVariableByName("A"); Variable b = variables.getVariableByName("B"); Variable c = variables.getVariableByName("C"); Variable d = variables.getVariableByName("D"); Variable e = variables.getVariableByName("E"); Variable g = variables.getVariableByName("G"); Variable h = variables.getVariableByName("H"); Variable i = variables.getVariableByName("I"); Variable hidden = variables.newMultinomialVariable("HiddenVar", Arrays.asList("TRUE", "FALSE")); DAG dag = new DAG(variables); dag.getParentSet(a).addParent(hidden); dag.getParentSet(b).addParent(hidden); dag.getParentSet(c).addParent(hidden); dag.getParentSet(d).addParent(hidden); dag.getParentSet(e).addParent(hidden); dag.getParentSet(g).addParent(hidden); dag.getParentSet(h).addParent(hidden); dag.getParentSet(i).addParent(hidden); System.out.println(dag.toString()); BayesianNetwork bn = new BayesianNetwork(dag); System.out.println(bn.toString()); BayesianNetworkWriter.save(bn, "networks/simulated/BNHiddenExample.bn"); }  static void main(String[] args);  }