org.apache.ignite.ml.preprocessing.encoding.target

## Class TargetEncoderPreprocessor<K,V>

- java.lang.Object
- - org.apache.ignite.ml.preprocessing.encoding.EncoderPreprocessor<K,V>
  - - org.apache.ignite.ml.preprocessing.encoding.target.TargetEncoderPreprocessor<K,V>

- Type Parameters:
    `K` - Type of a key in `upstream` data.
    `V` - Type of a value in `upstream` data.
  All Implemented Interfaces:
    Serializable, BiFunction<K,V,LabeledVector>, IgniteBiFunction<K,V,LabeledVector>, Preprocessor<K,V>

      public class TargetEncoderPreprocessor<K,V>
      extends EncoderPreprocessor<K,V>

  Preprocessing function that makes Target encoding. The Target Encoder Preprocessor encodes string values (categories) to double values in range [0.0, 1], where the value will be presented as a regularized mean target value of a category. alpha = 1 / (1 + exp(-(categorySize - min_samples_leaf) / beta)) encodedValue = globalTargetMean * (1 - alpha) + categoryTargetMean * alpha if categorySize == 1 then use globalTargetMean min_samples_leaf - minimum samples to take category average into account. beta - smoothing effect to balance categorical average vs prior. Higher value means stronger regularization. ref: https://dl.acm.org/doi/10.1145/507533.507538

  This preprocessor can transform multiple columns which indices are handled during training process. These indexes could be defined via .withEncodedFeature(featureIndex) call.

  NOTE: it does not add new column but change data in-place.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static long` | `serialVersionUID`
    `protected TargetEncodingMeta[]` | `targetCounters` Filling values.

    - ### Fields inherited from class org.apache.ignite.ml.preprocessing.encoding.EncoderPreprocessor

      `basePreprocessor, encodingValues, handledIndices, KEY_FOR_NULL_VALUES, labelFrequencies`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TargetEncoderPreprocessor(TargetEncodingMeta[] targetCounters, Preprocessor<K,V> basePreprocessor, Set<Integer> handledIndices)` Constructs a new instance of Frequency Encoder preprocessor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `LabeledVector` | `apply(K k, V v)` Applies this preprocessor.

    - ### 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.preprocessing.Preprocessor

      `map`

    - ### Methods inherited from interface org.apache.ignite.ml.math.functions.IgniteBiFunction

      `andThen`

    - ### Methods inherited from interface java.util.function.BiFunction

      `andThen`

- - ### Field Detail

    - #### serialVersionUID

          protected static final long serialVersionUID

      See Also:
        Constant Field Values

    - #### targetCounters

          protected final TargetEncodingMeta[] targetCounters

      Filling values.

  - ### Constructor Detail

    - #### TargetEncoderPreprocessor

          public TargetEncoderPreprocessor(TargetEncodingMeta[] targetCounters,
                                           Preprocessor<K,V> basePreprocessor,
                                           Set<Integer> handledIndices)

      Constructs a new instance of Frequency Encoder preprocessor.
      Parameters:
        `basePreprocessor` - Base preprocessor.
        `handledIndices` - Handled indices.

  - ### Method Detail

    - #### apply

          public LabeledVector apply(K k,
                                     V v)

      Applies this preprocessor.
      Parameters:
        `k` - Key.
        `v` - Value.
      Returns:
        Preprocessed row.

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