org.apache.ignite.ml.naivebayes.discrete

## Class DiscreteNaiveBayesTrainer

- java.lang.Object
- - org.apache.ignite.ml.trainers.DatasetTrainer<M,Double>
  - - org.apache.ignite.ml.trainers.SingleLabelDatasetTrainer<DiscreteNaiveBayesModel>
    - - org.apache.ignite.ml.naivebayes.discrete.DiscreteNaiveBayesTrainer

-     public class DiscreteNaiveBayesTrainer
      extends SingleLabelDatasetTrainer<DiscreteNaiveBayesModel>

  Trainer for the Discrete naive Bayes classification model. The trainer calculates prior probabilities from the input dataset. Prior probabilities can be also set by `setPriorProbabilities` or `withEquiprobableClasses`. If `equiprobableClasses` is set, the probalilities of all classes will be `1/k`, where `k` is classes count. Also, the trainer converts feature to discrete values by using `bucketThresholds`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.ignite.ml.trainers.DatasetTrainer

      `DatasetTrainer.EmptyDatasetException`

  - ### Field Summary

    - ### Fields inherited from class org.apache.ignite.ml.trainers.DatasetTrainer

      `envBuilder, environment`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DiscreteNaiveBayesTrainer()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<K,V> DiscreteNaiveBayesModel` | `fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> extractor)` Trains model based on the specified data.
    `boolean` | `isUpdateable(DiscreteNaiveBayesModel mdl)`
    `DiscreteNaiveBayesTrainer` | `resetProbabilitiesSettings()` Sets default settings `equiprobableClasses` to `false` and removes priorProbabilities.
    `DiscreteNaiveBayesTrainer` | `setBucketThresholds(double[][] bucketThresholds)` Sets buckest borders.
    `DiscreteNaiveBayesTrainer` | `setPriorProbabilities(double[] priorProbabilities)` Sets prior probabilities.
    `protected <K,V> DiscreteNaiveBayesModel` | `updateModel(DiscreteNaiveBayesModel mdl, DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> extractor)` Gets state of model in arguments, update in according to new data and return new model.
    `DiscreteNaiveBayesTrainer` | `withEquiprobableClasses()` Sets equal probability for all classes.

    - ### Methods inherited from class org.apache.ignite.ml.trainers.DatasetTrainer

      `fit, fit, fit, fit, fit, fit, getLastTrainedModelOrThrowEmptyDatasetException, identityTrainer, learningEnvironment, update, update, update, update, update, withConvertedLabels, withEnvironmentBuilder`

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

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

- - ### Constructor Detail

    - #### DiscreteNaiveBayesTrainer

          public DiscreteNaiveBayesTrainer()

  - ### Method Detail

    - #### fitWithInitializedDeployingContext

          public <K,V> DiscreteNaiveBayesModel fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder,
                                                                                  Preprocessor<K,V> extractor)

      Trains model based on the specified data.
      Specified by:
        `fitWithInitializedDeployingContext` in class `DatasetTrainer<DiscreteNaiveBayesModel,Double>`
      Type Parameters:
        `K` - Type of a key in `upstream` data.
        `V` - Type of a value in `upstream` data.
      Parameters:
        `datasetBuilder` - Dataset builder.
        `extractor` - Extractor of `UpstreamEntry` into `LabeledVector`.
      Returns:
        Model.

    - #### isUpdateable

          public boolean isUpdateable(DiscreteNaiveBayesModel mdl)

      Specified by:
        `isUpdateable` in class `DatasetTrainer<DiscreteNaiveBayesModel,Double>`
      Parameters:
        `mdl` - Model.
      Returns:
        True if current critical for training parameters correspond to parameters from last training.

    - #### updateModel

          protected <K,V> DiscreteNaiveBayesModel updateModel(DiscreteNaiveBayesModel mdl,
                                                              DatasetBuilder<K,V> datasetBuilder,
                                                              Preprocessor<K,V> extractor)

      Gets state of model in arguments, update in according to new data and return new model.
      Specified by:
        `updateModel` in class `DatasetTrainer<DiscreteNaiveBayesModel,Double>`
      Type Parameters:
        `K` - Type of a key in `upstream` data.
        `V` - Type of a value in `upstream` data.
      Parameters:
        `mdl` - Learned model.
        `datasetBuilder` - Dataset builder.
        `extractor` - Extractor of `UpstreamEntry` into `LabeledVector`.
      Returns:
        Updated model.

    - #### withEquiprobableClasses

          public DiscreteNaiveBayesTrainer withEquiprobableClasses()

      Sets equal probability for all classes.

    - #### setPriorProbabilities

          public DiscreteNaiveBayesTrainer setPriorProbabilities(double[] priorProbabilities)

      Sets prior probabilities.

    - #### setBucketThresholds

          public DiscreteNaiveBayesTrainer setBucketThresholds(double[][] bucketThresholds)

      Sets buckest borders.

    - #### resetProbabilitiesSettings

          public DiscreteNaiveBayesTrainer resetProbabilitiesSettings()

      Sets default settings `equiprobableClasses` to `false` and removes priorProbabilities.

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.11.0
Release Date | : September 11 2021