@Test public void test() throws Exception { DynamicVMP_FactoredFrontier.main(null); }
public static void main(String[] args) throws IOException { Random random = new Random(1); DynamicBayesianNetworkGenerator.setNumberOfContinuousVars(2); DynamicBayesianNetworkGenerator.setNumberOfDiscreteVars(5); DynamicBayesianNetworkGenerator.setNumberOfStates(3); DynamicBayesianNetwork extendedDBN = DynamicBayesianNetworkGenerator.generateDynamicNaiveBayes(random,2,true); System.out.println(extendedDBN.toString()); Variable classVar = extendedDBN.getDynamicVariables().getVariableByName("ClassVar"); DynamicBayesianNetworkSampler dynamicSampler = new DynamicBayesianNetworkSampler(extendedDBN); dynamicSampler.setHiddenVar(classVar); DataStream<DynamicDataInstance> dataPredict = dynamicSampler.sampleToDataBase(1,10); FactoredFrontierForDBN FFalgorithm = new FactoredFrontierForDBN(new VMP()); InferenceEngineForDBN.setInferenceAlgorithmForDBN(FFalgorithm); InferenceEngineForDBN.setModel(extendedDBN); int time = 0 ; UnivariateDistribution posterior = null; for (DynamicDataInstance instance : dataPredict) { if (instance.getTimeID()==0 && posterior != null) { InferenceEngineForDBN.reset(); time=0; } InferenceEngineForDBN.addDynamicEvidence(instance); InferenceEngineForDBN.runInference(); posterior = InferenceEngineForDBN.getFilteredPosterior(classVar); System.out.println("P(ClassVar|e[0:"+(time++)+"]) = "+posterior); } }
DynamicVMP_FactoredFrontier { public static void main(String[] args) throws IOException { Random random = new Random(1); DynamicBayesianNetworkGenerator.setNumberOfContinuousVars(2); DynamicBayesianNetworkGenerator.setNumberOfDiscreteVars(5); DynamicBayesianNetworkGenerator.setNumberOfStates(3); DynamicBayesianNetwork extendedDBN = DynamicBayesianNetworkGenerator.generateDynamicNaiveBayes(random,2,true); System.out.println(extendedDBN.toString()); Variable classVar = extendedDBN.getDynamicVariables().getVariableByName("ClassVar"); DynamicBayesianNetworkSampler dynamicSampler = new DynamicBayesianNetworkSampler(extendedDBN); dynamicSampler.setHiddenVar(classVar); DataStream<DynamicDataInstance> dataPredict = dynamicSampler.sampleToDataBase(1,10); FactoredFrontierForDBN FFalgorithm = new FactoredFrontierForDBN(new VMP()); InferenceEngineForDBN.setInferenceAlgorithmForDBN(FFalgorithm); InferenceEngineForDBN.setModel(extendedDBN); int time = 0 ; UnivariateDistribution posterior = null; for (DynamicDataInstance instance : dataPredict) { if (instance.getTimeID()==0 && posterior != null) { InferenceEngineForDBN.reset(); time=0; } InferenceEngineForDBN.addDynamicEvidence(instance); InferenceEngineForDBN.runInference(); posterior = InferenceEngineForDBN.getFilteredPosterior(classVar); System.out.println("P(ClassVar|e[0:"+(time++)+"]) = "+posterior); } } }
DynamicVMP_FactoredFrontier { public static void main(String[] args) throws IOException { Random random = new Random(1); DynamicBayesianNetworkGenerator.setNumberOfContinuousVars(2); DynamicBayesianNetworkGenerator.setNumberOfDiscreteVars(5); DynamicBayesianNetworkGenerator.setNumberOfStates(3); DynamicBayesianNetwork extendedDBN = DynamicBayesianNetworkGenerator.generateDynamicNaiveBayes(random,2,true); System.out.println(extendedDBN.toString()); Variable classVar = extendedDBN.getDynamicVariables().getVariableByName("ClassVar"); DynamicBayesianNetworkSampler dynamicSampler = new DynamicBayesianNetworkSampler(extendedDBN); dynamicSampler.setHiddenVar(classVar); DataStream<DynamicDataInstance> dataPredict = dynamicSampler.sampleToDataBase(1,10); FactoredFrontierForDBN FFalgorithm = new FactoredFrontierForDBN(new VMP()); InferenceEngineForDBN.setInferenceAlgorithmForDBN(FFalgorithm); InferenceEngineForDBN.setModel(extendedDBN); int time = 0 ; UnivariateDistribution posterior = null; for (DynamicDataInstance instance : dataPredict) { if (instance.getTimeID()==0 && posterior != null) { InferenceEngineForDBN.reset(); time=0; } InferenceEngineForDBN.addDynamicEvidence(instance); InferenceEngineForDBN.runInference(); posterior = InferenceEngineForDBN.getFilteredPosterior(classVar); System.out.println("P(ClassVar|e[0:"+(time++)+"]) = "+posterior); } }  }
DynamicVMP_FactoredFrontier { public static void main(String[] args) throws IOException { Random random = new Random(1); DynamicBayesianNetworkGenerator.setNumberOfContinuousVars(2); DynamicBayesianNetworkGenerator.setNumberOfDiscreteVars(5); DynamicBayesianNetworkGenerator.setNumberOfStates(3); DynamicBayesianNetwork extendedDBN = DynamicBayesianNetworkGenerator.generateDynamicNaiveBayes(random,2,true); System.out.println(extendedDBN.toString()); Variable classVar = extendedDBN.getDynamicVariables().getVariableByName("ClassVar"); DynamicBayesianNetworkSampler dynamicSampler = new DynamicBayesianNetworkSampler(extendedDBN); dynamicSampler.setHiddenVar(classVar); DataStream<DynamicDataInstance> dataPredict = dynamicSampler.sampleToDataBase(1,10); FactoredFrontierForDBN FFalgorithm = new FactoredFrontierForDBN(new VMP()); InferenceEngineForDBN.setInferenceAlgorithmForDBN(FFalgorithm); InferenceEngineForDBN.setModel(extendedDBN); int time = 0 ; UnivariateDistribution posterior = null; for (DynamicDataInstance instance : dataPredict) { if (instance.getTimeID()==0 && posterior != null) { InferenceEngineForDBN.reset(); time=0; } InferenceEngineForDBN.addDynamicEvidence(instance); InferenceEngineForDBN.runInference(); posterior = InferenceEngineForDBN.getFilteredPosterior(classVar); System.out.println("P(ClassVar|e[0:"+(time++)+"]) = "+posterior); } }  static void main(String[] args); }
DynamicVMP_FactoredFrontier { public static void main(String[] args) throws IOException { Random random = new Random(1); DynamicBayesianNetworkGenerator.setNumberOfContinuousVars(2); DynamicBayesianNetworkGenerator.setNumberOfDiscreteVars(5); DynamicBayesianNetworkGenerator.setNumberOfStates(3); DynamicBayesianNetwork extendedDBN = DynamicBayesianNetworkGenerator.generateDynamicNaiveBayes(random,2,true); System.out.println(extendedDBN.toString()); Variable classVar = extendedDBN.getDynamicVariables().getVariableByName("ClassVar"); DynamicBayesianNetworkSampler dynamicSampler = new DynamicBayesianNetworkSampler(extendedDBN); dynamicSampler.setHiddenVar(classVar); DataStream<DynamicDataInstance> dataPredict = dynamicSampler.sampleToDataBase(1,10); FactoredFrontierForDBN FFalgorithm = new FactoredFrontierForDBN(new VMP()); InferenceEngineForDBN.setInferenceAlgorithmForDBN(FFalgorithm); InferenceEngineForDBN.setModel(extendedDBN); int time = 0 ; UnivariateDistribution posterior = null; for (DynamicDataInstance instance : dataPredict) { if (instance.getTimeID()==0 && posterior != null) { InferenceEngineForDBN.reset(); time=0; } InferenceEngineForDBN.addDynamicEvidence(instance); InferenceEngineForDBN.runInference(); posterior = InferenceEngineForDBN.getFilteredPosterior(classVar); System.out.println("P(ClassVar|e[0:"+(time++)+"]) = "+posterior); } }  static void main(String[] args);  }