org.apache.ignite.ml.naivebayes.discrete

## Class DiscreteNaiveBayesModel

- java.lang.Object
- - org.apache.ignite.ml.naivebayes.discrete.DiscreteNaiveBayesModel

- All Implemented Interfaces:
    Serializable, AutoCloseable, DeployableObject, Exportable<DiscreteNaiveBayesModel>, IgniteModel<Vector,Double>, JSONWritable, Model<Vector,Double>, BayesModel<DiscreteNaiveBayesModel,Vector,Double>

      public class DiscreteNaiveBayesModel
      extends Object
      implements BayesModel<DiscreteNaiveBayesModel,Vector,Double>, JSONWritable, DeployableObject

  Discrete naive Bayes model which predicts result value `y` belongs to a class `C_k, k in [0..K]` as `p(C_k,y) =x_1*p_k1^x *...*x_i*p_ki^x_i`. Where `x_i` is a discrete feature, `p_ki` is a prior probability probability of class `p(x|C_k)`. Returns the number of the most possible class.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DiscreteNaiveBayesModel()`
    `DiscreteNaiveBayesModel(double[][][] probabilities, double[] clsProbabilities, double[] labels, double[][] bucketThresholds, DiscreteNaiveBayesSumsHolder sumsHolder)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static DiscreteNaiveBayesModel` | `fromJSON(Path path)` Loads DiscreteNaiveBayesModel from JSON file.
    `double[][]` | `getBucketThresholds()` A getter for bucketThresholds.
    `double[]` | `getClsProbabilities()` A getter for clsProbabilities.
    `List<Object>` | `getDependencies()` Returns dependencies of this object that can be object with class defined by client side and unknown for server.
    `double[]` | `getLabels()` A getter for labels.
    `double[][][]` | `getProbabilities()` A getter for probabilities.
    `DiscreteNaiveBayesSumsHolder` | `getSumsHolder()` A getter for sumsHolder.
    `Double` | `predict(Vector vector)` Make a prediction for the specified input arguments.
    `double[]` | `probabilityPowers(Vector vector)` Returns an array where the index correapons a label, and value corresponds `log(probability)` to be this label.
    `<P> void` | `saveModel(Exporter<DiscreteNaiveBayesModel,P> exporter, P path)` Save model by the given path.
    `void` | `toJSON(Path path)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.ignite.ml.IgniteModel

      `andBefore, andThen, andThen, close, combine, toString`

- - ### Constructor Detail

    - #### DiscreteNaiveBayesModel

          public DiscreteNaiveBayesModel(double[][][] probabilities,
                                         double[] clsProbabilities,
                                         double[] labels,
                                         double[][] bucketThresholds,
                                         DiscreteNaiveBayesSumsHolder sumsHolder)

      Parameters:
        `probabilities` - Probabilities of features for classes.
        `clsProbabilities` - Prior probabilities for classes.
        `labels` - Labels.
        `bucketThresholds` - The threshold to convert a feature to a binary value.
        `sumsHolder` - Amount values which are abouve the threshold per label.

    - #### DiscreteNaiveBayesModel

          public DiscreteNaiveBayesModel()

  - ### Method Detail

    - #### saveModel

          public <P> void saveModel(Exporter<DiscreteNaiveBayesModel,P> exporter,
                                    P path)

      Save model by the given path.
      Specified by:
        `saveModel` in interface `Exportable<DiscreteNaiveBayesModel>`
      Parameters:
        `exporter` - Exporter.
        `path` - Path to saved model.

    - #### predict

          public Double predict(Vector vector)

      Description copied from interface: `Model`
      Make a prediction for the specified input arguments.
      Specified by:
        `predict` in interface `Model<Vector,Double>`
      Parameters:
        `vector` - features vector.
      Returns:
        A label with max probability.

    - #### probabilityPowers

          public double[] probabilityPowers(Vector vector)

      Returns an array where the index correapons a label, and value corresponds `log(probability)` to be this label. The prior probabilities are not count.
      Specified by:
        `probabilityPowers` in interface `BayesModel<DiscreteNaiveBayesModel,Vector,Double>`

    - #### getProbabilities

          public double[][][] getProbabilities()

      A getter for probabilities.

    - #### getClsProbabilities

          public double[] getClsProbabilities()

      A getter for clsProbabilities.

    - #### getBucketThresholds

          public double[][] getBucketThresholds()

      A getter for bucketThresholds.

    - #### getLabels

          public double[] getLabels()

      A getter for labels.

    - #### getSumsHolder

          public DiscreteNaiveBayesSumsHolder getSumsHolder()

      A getter for sumsHolder.

    - #### getDependencies

          public List<Object> getDependencies()

      Returns dependencies of this object that can be object with class defined by client side and unknown for server.
      Specified by:
        `getDependencies` in interface `DeployableObject`

    - #### toJSON

          public void toJSON(Path path)

      Specified by:
        `toJSON` in interface `JSONWritable`

    - #### fromJSON

          public static DiscreteNaiveBayesModel fromJSON(Path path)

      Loads DiscreteNaiveBayesModel from JSON file.

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022