test_class.file: modules/ml/src/test/java/org/apache/ignite/ml/naivebayes/discrete/DiscreteNaiveBayesModelTest.java
test_class.identifier: DiscreteNaiveBayesModelTest
test_case.body: @Test
      public void testPredictWithTwoClasses() {
          double first = 1;
          double second = 2;
          double[][][] probabilities = new double[][][] {
              {{.5, .5}, {.2, .3, .5}, {2. / 3., 1. / 3.}, {.4, .1, .5}, {.5, .5}},
              {{0, 1}, {1. / 7, 2. / 7, 4. / 7}, {4. / 7, 3. / 7}, {2. / 7, 3. / 7, 2. / 7}, {4. / 7, 3. / 7,}}
          };
  
          double[] classProbabilities = new double[] {6. / 13, 7. / 13};
          double[][] thresholds = new double[][] {{.5}, {.2, .7}, {.5}, {.5, 1.5}, {.5}};
          DiscreteNaiveBayesModel mdl = new DiscreteNaiveBayesModel(probabilities, classProbabilities, new double[] {first, second}, thresholds, new DiscreteNaiveBayesSumsHolder());
          Vector observation = VectorUtils.of(2, 0, 1, 2, 0);
  
          Assert.assertEquals(second, mdl.predict(observation), 0.0001);
      }
test_case.class_method_signature: DiscreteNaiveBayesModelTest.testPredictWithTwoClasses()
test_case.full_signature: @Test public void testPredictWithTwoClasses()
test_case.identifier: testPredictWithTwoClasses
test_case.invocations: of assertEquals predict
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPredictWithTwoClasses()
focal_class.declarator: serialVersionUID = -127386523291350345L
focal_class.modifier: private static final
focal_class.original_string: private static final long serialVersionUID = -127386523291350345L;
focal_class.type: long
focal_class.var_name: serialVersionUID
focal_class.declarator: probabilities
focal_class.modifier: private final
focal_class.original_string: private final double[][][] probabilities;
focal_class.type: double[][][]
focal_class.var_name: probabilities
focal_class.declarator: clsProbabilities
focal_class.modifier: private final
focal_class.original_string: private final double[] clsProbabilities;
focal_class.type: double[]
focal_class.var_name: clsProbabilities
focal_class.declarator: labels
focal_class.modifier: private final
focal_class.original_string: private final double[] labels;
focal_class.type: double[]
focal_class.var_name: labels
focal_class.declarator: bucketThresholds
focal_class.modifier: private final
focal_class.original_string: private final double[][] bucketThresholds;
focal_class.type: double[][]
focal_class.var_name: bucketThresholds
focal_class.declarator: sumsHolder
focal_class.modifier: private final
focal_class.original_string: private final DiscreteNaiveBayesSumsHolder sumsHolder;
focal_class.type: DiscreteNaiveBayesSumsHolder
focal_class.var_name: sumsHolder
focal_class.file: modules/ml/src/main/java/org/apache/ignite/ml/naivebayes/discrete/DiscreteNaiveBayesModel.java
focal_class.identifier: DiscreteNaiveBayesModel
focal_class.interfaces: implements IgniteModel<Vector, Double>, Exportable<DiscreteNaiveBayesModel>, Serializable
focal_class.class_method_signature: DiscreteNaiveBayesModel.DiscreteNaiveBayesModel(double[][][] probabilities, double[] clsProbabilities, double[] labels,
          double[][] bucketThresholds, DiscreteNaiveBayesSumsHolder sumsHolder)
focal_class.full_signature: public  DiscreteNaiveBayesModel(double[][][] probabilities, double[] clsProbabilities, double[] labels,
          double[][] bucketThresholds, DiscreteNaiveBayesSumsHolder sumsHolder)
focal_class.identifier: DiscreteNaiveBayesModel
focal_class.modifiers: public
focal_class.parameters: (double[][][] probabilities, double[] clsProbabilities, double[] labels,
          double[][] bucketThresholds, DiscreteNaiveBayesSumsHolder sumsHolder)
focal_class.signature:  DiscreteNaiveBayesModel(double[][][] probabilities, double[] clsProbabilities, double[] labels,
          double[][] bucketThresholds, DiscreteNaiveBayesSumsHolder sumsHolder)
focal_class.class_method_signature: DiscreteNaiveBayesModel.saveModel(Exporter<DiscreteNaiveBayesModel, P> exporter, P path)
focal_class.full_signature: @Override public void saveModel(Exporter<DiscreteNaiveBayesModel, P> exporter, P path)
focal_class.identifier: saveModel
focal_class.modifiers: @Override public
focal_class.parameters: (Exporter<DiscreteNaiveBayesModel, P> exporter, P path)
focal_class.return: void
focal_class.signature: void saveModel(Exporter<DiscreteNaiveBayesModel, P> exporter, P path)
focal_class.class_method_signature: DiscreteNaiveBayesModel.predict(Vector vector)
focal_class.full_signature: @Override public Double predict(Vector vector)
focal_class.identifier: predict
focal_class.modifiers: @Override public
focal_class.parameters: (Vector vector)
focal_class.return: Double
focal_class.signature: Double predict(Vector vector)
focal_class.class_method_signature: DiscreteNaiveBayesModel.getProbabilities()
focal_class.full_signature: public double[][][] getProbabilities()
focal_class.identifier: getProbabilities
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double[][][]
focal_class.signature: double[][][] getProbabilities()
focal_class.class_method_signature: DiscreteNaiveBayesModel.getClsProbabilities()
focal_class.full_signature: public double[] getClsProbabilities()
focal_class.identifier: getClsProbabilities
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double[]
focal_class.signature: double[] getClsProbabilities()
focal_class.class_method_signature: DiscreteNaiveBayesModel.getBucketThresholds()
focal_class.full_signature: public double[][] getBucketThresholds()
focal_class.identifier: getBucketThresholds
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double[][]
focal_class.signature: double[][] getBucketThresholds()
focal_class.class_method_signature: DiscreteNaiveBayesModel.getSumsHolder()
focal_class.full_signature: public DiscreteNaiveBayesSumsHolder getSumsHolder()
focal_class.identifier: getSumsHolder
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: DiscreteNaiveBayesSumsHolder
focal_class.signature: DiscreteNaiveBayesSumsHolder getSumsHolder()
focal_class.class_method_signature: DiscreteNaiveBayesModel.toBucketNumber(double val, double[] thresholds)
focal_class.full_signature: private int toBucketNumber(double val, double[] thresholds)
focal_class.identifier: toBucketNumber
focal_class.modifiers: private
focal_class.parameters: (double val, double[] thresholds)
focal_class.return: int
focal_class.signature: int toBucketNumber(double val, double[] thresholds)
focal_method.body: @Override public Double predict(Vector vector) {
          double maxProbapilityPower = -Double.MAX_VALUE;
          int maxLabelIndex = -1;
  
          for (int i = 0; i < clsProbabilities.length; i++) {
              double probabilityPower = Math.log(clsProbabilities[i]);
  
              for (int j = 0; j < probabilities[0].length; j++) {
                  int x = toBucketNumber(vector.get(j), bucketThresholds[j]);
                  double p = probabilities[i][j][x];
                  probabilityPower += (p > 0 ? Math.log(p) : .0);
              }
  
              if (probabilityPower > maxProbapilityPower) {
                  maxLabelIndex = i;
                  maxProbapilityPower = probabilityPower;
              }
          }
          return labels[maxLabelIndex];
      }
focal_method.class_method_signature: DiscreteNaiveBayesModel.predict(Vector vector)
focal_method.full_signature: @Override public Double predict(Vector vector)
focal_method.identifier: predict
focal_method.invocations: log toBucketNumber get log
focal_method.modifiers: @Override public
focal_method.parameters: (Vector vector)
focal_method.return: Double
focal_method.signature: Double predict(Vector vector)