DiscreteNaiveBayesTrainer extends SingleLabelDatasetTrainer<DiscreteNaiveBayesModel> { public DiscreteNaiveBayesTrainer setBucketThresholds(double[][] bucketThresholds) { this.bucketThresholds = bucketThresholds; return this; }  @Override DiscreteNaiveBayesModel fitWithInitializedDeployingContext(DatasetBuilder<K, V> datasetBuilder,
                                                        Preprocessor<K, V> extractor); @Override boolean isUpdateable(DiscreteNaiveBayesModel mdl); DiscreteNaiveBayesTrainer withEquiprobableClasses(); DiscreteNaiveBayesTrainer setPriorProbabilities(double[] priorProbabilities); DiscreteNaiveBayesTrainer setBucketThresholds(double[][] bucketThresholds); DiscreteNaiveBayesTrainer resetProbabilitiesSettings();  }
@Test public void testReturnsCorrectPriorProbabilitiesWithDefferentThresholds() { double[][][] expectedPriorProbabilites = new double[][][] { { {4. / 8, 2. / 8, 2. / 8}, {.5, .5}, {1. / 8, 3. / 8, 2. / 8, 2. / 8}, {1. / 8, 2. / 8, 2. / 8, 3. / 8}}, { {2. / 4, 1. / 4, 1. / 4}, {1. / 4, 3. / 4}, {1. / 4, 0, 2. / 4, 1. / 4}, {2. / 4, 1. / 4, 1. / 4, 0}} }; DiscreteNaiveBayesModel model = trainer .setBucketThresholds(thresholds) .fit( new LocalDatasetBuilder<>(data, parts), new DoubleArrayVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.LAST) ); for (int i = 0; i < expectedPriorProbabilites.length; i++) { for (int j = 0; j < expectedPriorProbabilites[i].length; j++) Assert.assertArrayEquals(expectedPriorProbabilites[i][j], model.getProbabilities()[i][j], PRECISION); } }