org.apache.ignite.ml.composition.combinators.parallel

## Class TrainersParallelComposition<I,O,L>

- java.lang.Object
- - org.apache.ignite.ml.trainers.DatasetTrainer<IgniteModel<I,List<O>>,L>
  - - org.apache.ignite.ml.composition.combinators.parallel.TrainersParallelComposition<I,O,L>

- Type Parameters:
    `I` - Type of trainers inputs.
    `O` - Type of trainers outputs.
    `L` - Type of dataset labels.

      public class TrainersParallelComposition<I,O,L>
      extends DatasetTrainer<IgniteModel<I,List<O>>,L>

  This class represents a parallel composition of trainers. Parallel composition of trainers is a trainer itself which trains a list of trainers with same input and output. Training is done in following manner:

           1. Independently train all trainers on the same dataset and get a list of models.
           2. Combine models produced in step (1) into a ModelsParallelComposition.

  Updating is made in a similar fashion. Like in other trainers combinators we avoid to include type of contained trainers in type parameters because otherwise compositions of compositions would have a relatively complex generic type which will reduce readability.

- - ### 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
    `TrainersParallelComposition(List<T> trainers)` Construct an instance of this class from a list of trainers.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<K,V> IgniteModel<I,List<O>>` | `fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> preprocessor)` Trains model based on the specified data.
    `boolean` | `isUpdateable(IgniteModel<I,List<O>> mdl)` This method is never called, instead of constructing logic of update from `DatasetTrainer.isUpdateable(M)` and `DatasetTrainer.updateModel(M, org.apache.ignite.ml.dataset.DatasetBuilder<K, V>, org.apache.ignite.ml.preprocessing.Preprocessor<K, V>)` in this class we explicitly override update method.
    `static <I,O,M extends IgniteModel<I,O>,T extends DatasetTrainer<M,L>,L> TrainersParallelComposition<I,O,L>` | `of(List<T> trainers)` Create parallel composition of trainers contained in a given list.
    `<K,V> IgniteModel<I,List<O>>` | `update(IgniteModel<I,List<O>> mdl, DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> preprocessor)` Gets state of model in arguments, compare it with training parameters of trainer and if they are fit then trainer updates model in according to new data and return new model.
    `protected <K,V> IgniteModel<I,List<O>>` | `updateModel(IgniteModel<I,List<O>> mdl, DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> preprocessor)` This method is never called, instead of constructing logic of update from `DatasetTrainer.isUpdateable(IgniteModel)` and `DatasetTrainer.updateModel(IgniteModel, DatasetBuilder, Preprocessor)` in this class we explicitly override update method.

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

      `fit, fit, fit, fit, fit, fit, getLastTrainedModelOrThrowEmptyDatasetException, identityTrainer, learningEnvironment, 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

    - #### TrainersParallelComposition

          public TrainersParallelComposition(List<T> trainers)

      Construct an instance of this class from a list of trainers.
      Type Parameters:
        `T` - Type of trainer.
      Parameters:
        `trainers` - Trainers.

  - ### Method Detail

    - #### of

          public static <I,O,M extends IgniteModel<I,O>,T extends DatasetTrainer<M,L>,L> TrainersParallelComposition<I,O,L> of(List<T> trainers)

      Create parallel composition of trainers contained in a given list.
      Type Parameters:
        `I` - Type of input of model priduced by trainers.
        `O` - Type of output of model priduced by trainers.
        `M` - Type of model priduced by trainers.
        `T` - Type of trainers.
        `L` - Type of input of labels.
      Parameters:
        `trainers` - List of trainers.
      Returns:
        Parallel composition of trainers contained in a given list.

    - #### fitWithInitializedDeployingContext

          public <K,V> IgniteModel<I,List<O>> fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder,
                                                                                 Preprocessor<K,V> preprocessor)

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

    - #### update

          public <K,V> IgniteModel<I,List<O>> update(IgniteModel<I,List<O>> mdl,
                                                     DatasetBuilder<K,V> datasetBuilder,
                                                     Preprocessor<K,V> preprocessor)

      Gets state of model in arguments, compare it with training parameters of trainer and if they are fit then trainer updates model in according to new data and return new model. In other case trains new model.
      Overrides:
        `update` in class `DatasetTrainer<IgniteModel<I,List<O>>,L>`
      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.
        `preprocessor` - Extractor of `UpstreamEntry` into `LabeledVector`.
      Returns:
        Updated model.

    - #### isUpdateable

          public boolean isUpdateable(IgniteModel<I,List<O>> mdl)

      This method is never called, instead of constructing logic of update from `DatasetTrainer.isUpdateable(M)` and `DatasetTrainer.updateModel(M, org.apache.ignite.ml.dataset.DatasetBuilder<K, V>, org.apache.ignite.ml.preprocessing.Preprocessor<K, V>)` in this class we explicitly override update method.
      Specified by:
        `isUpdateable` in class `DatasetTrainer<IgniteModel<I,List<O>>,L>`
      Parameters:
        `mdl` - Model.
      Returns:
        True if current critical for training parameters correspond to parameters from last training.

    - #### updateModel

          protected <K,V> IgniteModel<I,List<O>> updateModel(IgniteModel<I,List<O>> mdl,
                                                             DatasetBuilder<K,V> datasetBuilder,
                                                             Preprocessor<K,V> preprocessor)

      This method is never called, instead of constructing logic of update from `DatasetTrainer.isUpdateable(IgniteModel)` and `DatasetTrainer.updateModel(IgniteModel, DatasetBuilder, Preprocessor)` in this class we explicitly override update method.
      Specified by:
        `updateModel` in class `DatasetTrainer<IgniteModel<I,List<O>>,L>`
      Type Parameters:
        `K` - Type of a key in `upstream` data.
        `V` - Type of a value in `upstream` data.
      Parameters:
        `mdl` - Model.
        `datasetBuilder` - Dataset builder.
        `preprocessor` - Extractor of `UpstreamEntry` into `LabeledVector`.
      Returns:
        Updated model.

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