@Test public void test() throws Exception { NaiveBayesClassifierDemo.main(null); }
public static void main(String[] args) throws WrongConfigurationException{ BayesianNetworkGenerator.loadOptions(); BayesianNetworkGenerator.setSeed(0); BayesianNetworkGenerator.setNumberOfGaussianVars(10); BayesianNetworkGenerator.setNumberOfMultinomialVars(10, 5); BayesianNetwork bn = BayesianNetworkGenerator.generateNaiveBayes(2); System.out.println(bn.toString()); int sampleSize = 100; BayesianNetworkSampler sampler = new BayesianNetworkSampler(bn); sampler.setMARVar(bn.getVariables().getVariableById(0),0.2); sampler.setMARVar(bn.getVariables().getVariableById(3),0.2); sampler.setMARVar(bn.getVariables().getVariableById(8),0.2); DataStream<DataInstance> data = sampler.sampleToDataStream(sampleSize); long time = System.nanoTime(); NaiveBayesClassifier model = new NaiveBayesClassifier(data.getAttributes()); model.setClassName(data.getAttributes().getFullListOfAttributes().get(data.getAttributes().getFullListOfAttributes().size() - 1).getName()); model.updateModel(data); BayesianNetwork nbClassifier = model.getModel(); System.out.println(nbClassifier.toString()); System.out.println("Time: "+(System.nanoTime()-time)/1000000000.0); }
NaiveBayesClassifierDemo { public static void main(String[] args) throws WrongConfigurationException{ BayesianNetworkGenerator.loadOptions(); BayesianNetworkGenerator.setSeed(0); BayesianNetworkGenerator.setNumberOfGaussianVars(10); BayesianNetworkGenerator.setNumberOfMultinomialVars(10, 5); BayesianNetwork bn = BayesianNetworkGenerator.generateNaiveBayes(2); System.out.println(bn.toString()); int sampleSize = 100; BayesianNetworkSampler sampler = new BayesianNetworkSampler(bn); sampler.setMARVar(bn.getVariables().getVariableById(0),0.2); sampler.setMARVar(bn.getVariables().getVariableById(3),0.2); sampler.setMARVar(bn.getVariables().getVariableById(8),0.2); DataStream<DataInstance> data = sampler.sampleToDataStream(sampleSize); long time = System.nanoTime(); NaiveBayesClassifier model = new NaiveBayesClassifier(data.getAttributes()); model.setClassName(data.getAttributes().getFullListOfAttributes().get(data.getAttributes().getFullListOfAttributes().size() - 1).getName()); model.updateModel(data); BayesianNetwork nbClassifier = model.getModel(); System.out.println(nbClassifier.toString()); System.out.println("Time: "+(System.nanoTime()-time)/1000000000.0); } }
NaiveBayesClassifierDemo { public static void main(String[] args) throws WrongConfigurationException{ BayesianNetworkGenerator.loadOptions(); BayesianNetworkGenerator.setSeed(0); BayesianNetworkGenerator.setNumberOfGaussianVars(10); BayesianNetworkGenerator.setNumberOfMultinomialVars(10, 5); BayesianNetwork bn = BayesianNetworkGenerator.generateNaiveBayes(2); System.out.println(bn.toString()); int sampleSize = 100; BayesianNetworkSampler sampler = new BayesianNetworkSampler(bn); sampler.setMARVar(bn.getVariables().getVariableById(0),0.2); sampler.setMARVar(bn.getVariables().getVariableById(3),0.2); sampler.setMARVar(bn.getVariables().getVariableById(8),0.2); DataStream<DataInstance> data = sampler.sampleToDataStream(sampleSize); long time = System.nanoTime(); NaiveBayesClassifier model = new NaiveBayesClassifier(data.getAttributes()); model.setClassName(data.getAttributes().getFullListOfAttributes().get(data.getAttributes().getFullListOfAttributes().size() - 1).getName()); model.updateModel(data); BayesianNetwork nbClassifier = model.getModel(); System.out.println(nbClassifier.toString()); System.out.println("Time: "+(System.nanoTime()-time)/1000000000.0); }  }
NaiveBayesClassifierDemo { public static void main(String[] args) throws WrongConfigurationException{ BayesianNetworkGenerator.loadOptions(); BayesianNetworkGenerator.setSeed(0); BayesianNetworkGenerator.setNumberOfGaussianVars(10); BayesianNetworkGenerator.setNumberOfMultinomialVars(10, 5); BayesianNetwork bn = BayesianNetworkGenerator.generateNaiveBayes(2); System.out.println(bn.toString()); int sampleSize = 100; BayesianNetworkSampler sampler = new BayesianNetworkSampler(bn); sampler.setMARVar(bn.getVariables().getVariableById(0),0.2); sampler.setMARVar(bn.getVariables().getVariableById(3),0.2); sampler.setMARVar(bn.getVariables().getVariableById(8),0.2); DataStream<DataInstance> data = sampler.sampleToDataStream(sampleSize); long time = System.nanoTime(); NaiveBayesClassifier model = new NaiveBayesClassifier(data.getAttributes()); model.setClassName(data.getAttributes().getFullListOfAttributes().get(data.getAttributes().getFullListOfAttributes().size() - 1).getName()); model.updateModel(data); BayesianNetwork nbClassifier = model.getModel(); System.out.println(nbClassifier.toString()); System.out.println("Time: "+(System.nanoTime()-time)/1000000000.0); }  static void main(String[] args); }
NaiveBayesClassifierDemo { public static void main(String[] args) throws WrongConfigurationException{ BayesianNetworkGenerator.loadOptions(); BayesianNetworkGenerator.setSeed(0); BayesianNetworkGenerator.setNumberOfGaussianVars(10); BayesianNetworkGenerator.setNumberOfMultinomialVars(10, 5); BayesianNetwork bn = BayesianNetworkGenerator.generateNaiveBayes(2); System.out.println(bn.toString()); int sampleSize = 100; BayesianNetworkSampler sampler = new BayesianNetworkSampler(bn); sampler.setMARVar(bn.getVariables().getVariableById(0),0.2); sampler.setMARVar(bn.getVariables().getVariableById(3),0.2); sampler.setMARVar(bn.getVariables().getVariableById(8),0.2); DataStream<DataInstance> data = sampler.sampleToDataStream(sampleSize); long time = System.nanoTime(); NaiveBayesClassifier model = new NaiveBayesClassifier(data.getAttributes()); model.setClassName(data.getAttributes().getFullListOfAttributes().get(data.getAttributes().getFullListOfAttributes().size() - 1).getName()); model.updateModel(data); BayesianNetwork nbClassifier = model.getModel(); System.out.println(nbClassifier.toString()); System.out.println("Time: "+(System.nanoTime()-time)/1000000000.0); }  static void main(String[] args);  }