org.apache.ignite.ml.preprocessing.encoding.stringencoder

## Class StringEncoderPreprocessor<K,V>

- java.lang.Object
- - org.apache.ignite.ml.preprocessing.encoding.EncoderPreprocessor<K,V>
  - - org.apache.ignite.ml.preprocessing.encoding.stringencoder.StringEncoderPreprocessor<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>, DeployableObject, IgniteBiFunction<K,V,LabeledVector>, Preprocessor<K,V>

      public final class StringEncoderPreprocessor<K,V>
      extends EncoderPreprocessor<K,V>
      implements DeployableObject

  Preprocessing function that makes String encoding. The String Encoder Preprocessor encodes string values (categories) to double values in range [0.0, amountOfCategories), where the most popular value will be presented as 0.0 and the least popular value presented with amountOfCategories-1 value.

  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.

  There is only a one strategy regarding how StringEncoder will handle unseen labels when you have fit a StringEncoder on one dataset and then use it to transform another: put unseen labels in a special additional bucket, at index is equal amountOfCategories.

  See Also:
    Serialized Form

- - ### Field Summary

    - ### 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
    `StringEncoderPreprocessor(Map<String,Integer>[] encodingValues, Preprocessor<K,V> basePreprocessor, Set<Integer> handledIndices)` Constructs a new instance of String 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.
    `List<Object>` | `getDependencies()` Returns dependencies of this object that can be object with class defined by client side and unknown for server.

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

- - ### Constructor Detail

    - #### StringEncoderPreprocessor

          public StringEncoderPreprocessor(Map<String,Integer>[] encodingValues,
                                           Preprocessor<K,V> basePreprocessor,
                                           Set<Integer> handledIndices)

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

  - ### Method Detail

    - #### apply

          public LabeledVector apply(K k,
                                     V v)

      Applies this preprocessor.
      Specified by:
        `apply` in interface `BiFunction<K,V,LabeledVector>`
      Parameters:
        `k` - Key.
        `v` - Value.
      Returns:
        Preprocessed row.

    - #### getDependencies

          public List<Object> getDependencies()

      Returns dependencies of this object that can be object with class defined by client side and unknown for server.
      Specified by:
        `getDependencies` in interface `DeployableObject`

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