org.apache.ignite.ml.selection.cv

## Class AbstractCrossValidation<M extends IgniteModel<Vector,Double>,K,V>

- java.lang.Object
- - org.apache.ignite.ml.selection.cv.AbstractCrossValidation<M,K,V>

- Type Parameters:
    `M` - Type of model.
    `K` - Type of a key in `upstream` data.
    `V` - Type of a value in `upstream` data.
  All Implemented Interfaces:
    Serializable
  Direct Known Subclasses:
    CrossValidation, DebugCrossValidation

      public abstract class AbstractCrossValidation<M extends IgniteModel<Vector,Double>,K,V>
      extends Object
      implements Serializable

  Cross validation score calculator. Cross validation is an approach that allows to avoid overfitting that is made the following way: the training set is split into k smaller sets. The following procedure is followed for each of the k “folds”:
  - A model is trained using k-1 of the folds as training data;
  - the resulting model is validated on the remaining part of the data (i.e., it is used as a test set to compute a performance measure such as accuracy).
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `AbstractCrossValidation.TaskResult` Represents the scores and map of parameters.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `amountOfFolds` Amount of folds.
    `protected LearningEnvironmentBuilder` | `envBuilder` Learning environment builder.
    `protected LearningEnvironment` | `environment` Learning Environment.
    `protected IgniteBiPredicate<K,V>` | `filter` Filter.
    `protected boolean` | `isRunningOnPipeline` Execution over the pipeline or the chain of preprocessors and separate trainer, otherwise.
    `protected UniformMapper<K,V>` | `mapper` Mapper.
    `protected Metric` | `metric` Metric.
    `protected ParamGrid` | `paramGrid` Parameter grid.
    `protected int` | `parts` Parts.
    `protected Pipeline<K,V,Integer,Double>` | `pipeline` Pipeline.
    `protected Preprocessor<K,V>` | `preprocessor` Preprocessor.
    `protected DatasetTrainer<M,Double>` | `trainer` Trainer.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractCrossValidation()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `AbstractCrossValidation<M,K,V>` | `isRunningOnPipeline(boolean runningOnPipeline)`
    `protected double[]` | `score(Function<IgniteBiPredicate<K,V>,DatasetBuilder<K,V>> datasetBuilderSupplier)` Computes cross-validated metrics.
    `abstract double[]` | `scoreByFolds()` Calculates score by folds.
    `protected double[]` | `scorePipeline(Function<IgniteBiPredicate<K,V>,DatasetBuilder<K,V>> datasetBuilderSupplier)` Computes cross-validated metrics.
    `CrossValidationResult` | `tuneHyperParameters()` Finds the best set of hyper-parameters based on parameter search strategy.
    `AbstractCrossValidation<M,K,V>` | `withAmountOfFolds(int amountOfFolds)`
    `AbstractCrossValidation<M,K,V>` | `withEnvironmentBuilder(LearningEnvironmentBuilder envBuilder)` Changes learning Environment.
    `AbstractCrossValidation<M,K,V>` | `withFilter(IgniteBiPredicate<K,V> filter)`
    `AbstractCrossValidation<M,K,V>` | `withMapper(UniformMapper<K,V> mapper)`
    `AbstractCrossValidation<M,K,V>` | `withMetric(MetricName metric)`
    `AbstractCrossValidation<M,K,V>` | `withParamGrid(ParamGrid paramGrid)`
    `AbstractCrossValidation<M,K,V>` | `withPipeline(Pipeline<K,V,Integer,Double> pipeline)`
    `AbstractCrossValidation<M,K,V>` | `withPreprocessor(Preprocessor<K,V> preprocessor)`
    `AbstractCrossValidation<M,K,V>` | `withTrainer(DatasetTrainer<M,Double> trainer)`

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

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

- - ### Field Detail

    - #### envBuilder

          protected LearningEnvironmentBuilder envBuilder

      Learning environment builder.

    - #### environment

          protected LearningEnvironment environment

      Learning Environment.

    - #### trainer

          protected DatasetTrainer<M extends IgniteModel<Vector,Double>,Double> trainer

      Trainer.

    - #### pipeline

          protected Pipeline<K,V,Integer,Double> pipeline

      Pipeline.

    - #### metric

          protected Metric metric

      Metric.

    - #### preprocessor

          protected Preprocessor<K,V> preprocessor

      Preprocessor.

    - #### filter

          protected IgniteBiPredicate<K,V> filter

      Filter.

    - #### amountOfFolds

          protected int amountOfFolds

      Amount of folds.

    - #### parts

          protected int parts

      Parts.

    - #### paramGrid

          protected ParamGrid paramGrid

      Parameter grid.

    - #### isRunningOnPipeline

          protected boolean isRunningOnPipeline

      Execution over the pipeline or the chain of preprocessors and separate trainer, otherwise.

    - #### mapper

          protected UniformMapper<K,V> mapper

      Mapper.

  - ### Constructor Detail

    - #### AbstractCrossValidation

          public AbstractCrossValidation()

  - ### Method Detail

    - #### tuneHyperParameters

          public CrossValidationResult tuneHyperParameters()

      Finds the best set of hyper-parameters based on parameter search strategy.

    - #### scoreByFolds

          public abstract double[] scoreByFolds()

      Calculates score by folds.

    - #### score

          protected double[] score(Function<IgniteBiPredicate<K,V>,DatasetBuilder<K,V>> datasetBuilderSupplier)

      Computes cross-validated metrics.
      Parameters:
        `datasetBuilderSupplier` - Dataset builder supplier.
      Returns:
        Array of scores of the estimator for each run of the cross validation.

    - #### scorePipeline

          protected double[] scorePipeline(Function<IgniteBiPredicate<K,V>,DatasetBuilder<K,V>> datasetBuilderSupplier)

      Computes cross-validated metrics.
      Parameters:
        `datasetBuilderSupplier` - Dataset builder supplier.
      Returns:
        Array of scores of the estimator for each run of the cross validation.

    - #### withTrainer

          public AbstractCrossValidation<M,K,V> withTrainer(DatasetTrainer<M,Double> trainer)

      Parameters:
        `trainer` - Trainer.

    - #### withMetric

          public AbstractCrossValidation<M,K,V> withMetric(MetricName metric)

      Parameters:
        `metric` - Metric.

    - #### withPreprocessor

          public AbstractCrossValidation<M,K,V> withPreprocessor(Preprocessor<K,V> preprocessor)

      Parameters:
        `preprocessor` - Preprocessor.

    - #### withFilter

          public AbstractCrossValidation<M,K,V> withFilter(IgniteBiPredicate<K,V> filter)

      Parameters:
        `filter` - Filter.

    - #### withAmountOfFolds

          public AbstractCrossValidation<M,K,V> withAmountOfFolds(int amountOfFolds)

      Parameters:
        `amountOfFolds` - Amount of folds.

    - #### withParamGrid

          public AbstractCrossValidation<M,K,V> withParamGrid(ParamGrid paramGrid)

      Parameters:
        `paramGrid` - Parameter grid.

    - #### isRunningOnPipeline

          public AbstractCrossValidation<M,K,V> isRunningOnPipeline(boolean runningOnPipeline)

      Parameters:
        `runningOnPipeline` - Running on pipeline.

    - #### withEnvironmentBuilder

          public AbstractCrossValidation<M,K,V> withEnvironmentBuilder(LearningEnvironmentBuilder envBuilder)

      Changes learning Environment.
      Parameters:
        `envBuilder` - Learning environment builder.

    - #### withPipeline

          public AbstractCrossValidation<M,K,V> withPipeline(Pipeline<K,V,Integer,Double> pipeline)

      Parameters:
        `pipeline` - Pipeline.

    - #### withMapper

          public AbstractCrossValidation<M,K,V> withMapper(UniformMapper<K,V> mapper)

      Parameters:
        `mapper` - Mapper.

2020 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.9.0
Release Date | : October 15 2020