@Test public void test() throws Exception { CreatingBayesianNetworks.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"); DAG dag = new DAG(variables); dag.getParentSet(e).addParent(a); dag.getParentSet(e).addParent(b); dag.getParentSet(h).addParent(a); dag.getParentSet(h).addParent(b); dag.getParentSet(i).addParent(a); dag.getParentSet(i).addParent(b); dag.getParentSet(i).addParent(c); dag.getParentSet(i).addParent(d); dag.getParentSet(g).addParent(c); dag.getParentSet(g).addParent(d); if (dag.containCycles()) { try { } catch (Exception ex) { throw new IllegalArgumentException(ex); } } System.out.println(dag.toString()); BayesianNetwork bn = new BayesianNetwork(dag); System.out.println(bn.toString()); double logProb = 0; for (DataInstance instance : data) { logProb += bn.getLogProbabiltyOf(instance); } System.out.println(logProb); BayesianNetworkWriter.save(bn, "networks/simulated/BNExample.bn"); }
CreatingBayesianNetworks { 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"); DAG dag = new DAG(variables); dag.getParentSet(e).addParent(a); dag.getParentSet(e).addParent(b); dag.getParentSet(h).addParent(a); dag.getParentSet(h).addParent(b); dag.getParentSet(i).addParent(a); dag.getParentSet(i).addParent(b); dag.getParentSet(i).addParent(c); dag.getParentSet(i).addParent(d); dag.getParentSet(g).addParent(c); dag.getParentSet(g).addParent(d); if (dag.containCycles()) { try { } catch (Exception ex) { throw new IllegalArgumentException(ex); } } System.out.println(dag.toString()); BayesianNetwork bn = new BayesianNetwork(dag); System.out.println(bn.toString()); double logProb = 0; for (DataInstance instance : data) { logProb += bn.getLogProbabiltyOf(instance); } System.out.println(logProb); BayesianNetworkWriter.save(bn, "networks/simulated/BNExample.bn"); } }
CreatingBayesianNetworks { 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"); DAG dag = new DAG(variables); dag.getParentSet(e).addParent(a); dag.getParentSet(e).addParent(b); dag.getParentSet(h).addParent(a); dag.getParentSet(h).addParent(b); dag.getParentSet(i).addParent(a); dag.getParentSet(i).addParent(b); dag.getParentSet(i).addParent(c); dag.getParentSet(i).addParent(d); dag.getParentSet(g).addParent(c); dag.getParentSet(g).addParent(d); if (dag.containCycles()) { try { } catch (Exception ex) { throw new IllegalArgumentException(ex); } } System.out.println(dag.toString()); BayesianNetwork bn = new BayesianNetwork(dag); System.out.println(bn.toString()); double logProb = 0; for (DataInstance instance : data) { logProb += bn.getLogProbabiltyOf(instance); } System.out.println(logProb); BayesianNetworkWriter.save(bn, "networks/simulated/BNExample.bn"); }  }
CreatingBayesianNetworks { 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"); DAG dag = new DAG(variables); dag.getParentSet(e).addParent(a); dag.getParentSet(e).addParent(b); dag.getParentSet(h).addParent(a); dag.getParentSet(h).addParent(b); dag.getParentSet(i).addParent(a); dag.getParentSet(i).addParent(b); dag.getParentSet(i).addParent(c); dag.getParentSet(i).addParent(d); dag.getParentSet(g).addParent(c); dag.getParentSet(g).addParent(d); if (dag.containCycles()) { try { } catch (Exception ex) { throw new IllegalArgumentException(ex); } } System.out.println(dag.toString()); BayesianNetwork bn = new BayesianNetwork(dag); System.out.println(bn.toString()); double logProb = 0; for (DataInstance instance : data) { logProb += bn.getLogProbabiltyOf(instance); } System.out.println(logProb); BayesianNetworkWriter.save(bn, "networks/simulated/BNExample.bn"); }  static void main(String[] args); }
CreatingBayesianNetworks { 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"); DAG dag = new DAG(variables); dag.getParentSet(e).addParent(a); dag.getParentSet(e).addParent(b); dag.getParentSet(h).addParent(a); dag.getParentSet(h).addParent(b); dag.getParentSet(i).addParent(a); dag.getParentSet(i).addParent(b); dag.getParentSet(i).addParent(c); dag.getParentSet(i).addParent(d); dag.getParentSet(g).addParent(c); dag.getParentSet(g).addParent(d); if (dag.containCycles()) { try { } catch (Exception ex) { throw new IllegalArgumentException(ex); } } System.out.println(dag.toString()); BayesianNetwork bn = new BayesianNetwork(dag); System.out.println(bn.toString()); double logProb = 0; for (DataInstance instance : data) { logProb += bn.getLogProbabiltyOf(instance); } System.out.println(logProb); BayesianNetworkWriter.save(bn, "networks/simulated/BNExample.bn"); }  static void main(String[] args);  }