org.apache.ignite.ml.regressions.linear

## Class LinearRegressionSGDTrainer<P extends Serializable>

- java.lang.Object
- - org.apache.ignite.ml.trainers.DatasetTrainer<M,Double>
  - - org.apache.ignite.ml.trainers.SingleLabelDatasetTrainer<LinearRegressionModel>
    - - org.apache.ignite.ml.regressions.linear.LinearRegressionSGDTrainer<P>

-     public class LinearRegressionSGDTrainer<P extends Serializable>
      extends SingleLabelDatasetTrainer<LinearRegressionModel>

  Trainer of the linear regression model based on stochastic gradient descent algorithm.

- - ### 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
    `LinearRegressionSGDTrainer(UpdatesStrategy<? super MultilayerPerceptron,P> updatesStgy)` Constructs a new instance of linear regression SGD trainer.
    `LinearRegressionSGDTrainer(UpdatesStrategy<? super MultilayerPerceptron,P> updatesStgy, int maxIterations, int batchSize, int locIterations, long seed)` Constructs a new instance of linear regression SGD trainer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<K,V> LinearRegressionModel` | `fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> extractor)` Trains model based on the specified data.
    `int` | `getBatchSize()` Get the batch size.
    `int` | `getLocIterations()` Get the amount of local iterations.
    `int` | `getMaxIterations()` Get the max amount of iterations.
    `long` | `getSeed()` Get the seed for random generator.
    `UpdatesStrategy<? super MultilayerPerceptron,P>` | `getUpdatesStgy()` Get the update strategy.
    `boolean` | `isUpdateable(LinearRegressionModel mdl)`
    `protected <K,V> LinearRegressionModel` | `updateModel(LinearRegressionModel 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.
    `LinearRegressionSGDTrainer<P>` | `withBatchSize(int batchSize)` Set up the batchSize parameter.
    `LinearRegressionSGDTrainer<P>` | `withLocIterations(int amountOfLocIterations)` Set up the amount of local iterations of SGD algorithm.
    `LinearRegressionSGDTrainer<P>` | `withMaxIterations(int maxIterations)` Set up the max amount of iterations before convergence.
    `LinearRegressionSGDTrainer<P>` | `withSeed(long seed)` Set up the random seed parameter.

    - ### 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

    - #### LinearRegressionSGDTrainer

          public LinearRegressionSGDTrainer(UpdatesStrategy<? super MultilayerPerceptron,P> updatesStgy,
                                            int maxIterations,
                                            int batchSize,
                                            int locIterations,
                                            long seed)

      Constructs a new instance of linear regression SGD trainer.
      Parameters:
        `updatesStgy` - Update strategy.
        `maxIterations` - Max number of iteration.
        `batchSize` - Batch size.
        `locIterations` - Number of local iterations.
        `seed` - Seed for random generator.

    - #### LinearRegressionSGDTrainer

          public LinearRegressionSGDTrainer(UpdatesStrategy<? super MultilayerPerceptron,P> updatesStgy)

      Constructs a new instance of linear regression SGD trainer.

  - ### Method Detail

    - #### fitWithInitializedDeployingContext

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

      Trains model based on the specified data.
      Specified by:
        `fitWithInitializedDeployingContext` in class `DatasetTrainer<LinearRegressionModel,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.

    - #### updateModel

          protected <K,V> LinearRegressionModel updateModel(LinearRegressionModel 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<LinearRegressionModel,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.

    - #### isUpdateable

          public boolean isUpdateable(LinearRegressionModel mdl)

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

    - #### withMaxIterations

          public LinearRegressionSGDTrainer<P> withMaxIterations(int maxIterations)

      Set up the max amount of iterations before convergence.
      Parameters:
        `maxIterations` - The parameter value.
      Returns:
        Model with new max number of iterations before convergence parameter value.

    - #### withBatchSize

          public LinearRegressionSGDTrainer<P> withBatchSize(int batchSize)

      Set up the batchSize parameter.
      Parameters:
        `batchSize` - The size of learning batch.
      Returns:
        Trainer with new batch size parameter value.

    - #### withLocIterations

          public LinearRegressionSGDTrainer<P> withLocIterations(int amountOfLocIterations)

      Set up the amount of local iterations of SGD algorithm.
      Parameters:
        `amountOfLocIterations` - The parameter value.
      Returns:
        Trainer with new locIterations parameter value.

    - #### withSeed

          public LinearRegressionSGDTrainer<P> withSeed(long seed)

      Set up the random seed parameter.
      Parameters:
        `seed` - Seed for random generator.
      Returns:
        Trainer with new seed parameter value.

    - #### getUpdatesStgy

          public UpdatesStrategy<? super MultilayerPerceptron,P> getUpdatesStgy()

      Get the update strategy.
      Returns:
        The property value.

    - #### getMaxIterations

          public int getMaxIterations()

      Get the max amount of iterations.
      Returns:
        The property value.

    - #### getBatchSize

          public int getBatchSize()

      Get the batch size.
      Returns:
        The property value.

    - #### getLocIterations

          public int getLocIterations()

      Get the amount of local iterations.
      Returns:
        The property value.

    - #### getSeed

          public long getSeed()

      Get the seed for random generator.
      Returns:
        The property value.

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022