org.apache.ignite.ml.dataset.feature.extractor

## Class Vectorizer<K,V,C extends Serializable,L>

- java.lang.Object
- - org.apache.ignite.ml.dataset.feature.extractor.Vectorizer<K,V,C,L>

- Type Parameters:
    `K` - Type of keys in upstream.
    `V` - Type of values in upstream.
    `C` - Type of "coordinate" - index of feature value in upstream object.
    `L` - Type of label for resulting vectors.
  All Implemented Interfaces:
    Serializable, BiFunction<K,V,LabeledVector>, IgniteBiFunction<K,V,LabeledVector>, Preprocessor<K,V>, FeatureLabelExtractor<K,V,L>
  Direct Known Subclasses:
    ExtractionUtils.DefaultLabelVectorizer, ExtractionUtils.ObjectLabelVectorizer, LabeledDummyVectorizer, Vectorizer.VectorizerAdapter

      public abstract class Vectorizer<K,V,C extends Serializable,L>
      extends Object
      implements FeatureLabelExtractor<K,V,L>

  Class for extracting labeled vectors from upstream. This is an abstract class providing API for extracting feature and label values by "coordinates" of them from upstream objects. For example `BinaryObject` can be upstream object and coordinates for them are names of fields with double-values.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Vectorizer.LabelCoordinate` Shotrcuts for coordinates in feature vector.
    `static class` | `Vectorizer.VectorizerAdapter<K,V,C extends Serializable,L>` Utility class for convenient overridings.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Vectorizer(C... coords)` Creates an instance of Vectorizer.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract List<C>` | `allCoords(K key, V value)` Returns list of all coordinate with feature values.
    `LabeledVector<L>` | `apply(K key, V value)` Extracts labeled vector from upstream object.
    `protected Vector` | `createVector(int size)` Create an instance of vector.
    `Vectorizer<K,V,C,L>` | `exclude(C... coords)` Exclude these coordinates from result vector.
    `LabeledVector<L>` | `extract(K k, V v)` Extract `LabeledVector` from key and value.
    `protected abstract Serializable` | `feature(C coord, K key, V value)` Extracts feature value by given coordinate.
    `protected abstract L` | `label(C coord, K key, V value)` Extract label value by given coordinate.
    `Vectorizer<K,V,C,L>` | `labeled(C labelCoord)` Sets label coordinate for Vectorizer.
    `Vectorizer<K,V,C,L>` | `labeled(Vectorizer.LabelCoordinate labelCoord)` Sets label coordinate for Vectorizer.
    `protected abstract L` | `zero()` Returns default label value for unlabeled data.

    - ### 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.trainers.FeatureLabelExtractor

      `extractFeatures, extractLabel`

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

    - #### Vectorizer

          public Vectorizer(C... coords)

      Creates an instance of Vectorizer.
      Parameters:
        `coords` - Coordinates for feature extraction. If array is empty then Vectorizer will extract all fields from upstream object.

  - ### Method Detail

    - #### apply

          public LabeledVector<L> apply(K key,
                                        V value)

      Extracts labeled vector from upstream object.
      Specified by:
        `apply` in interface `BiFunction<K,V,LabeledVector>`
      Parameters:
        `key` - Key.
        `value` - Value.
      Returns:
        vector.

    - #### labeled

          public Vectorizer<K,V,C,L> labeled(C labelCoord)

      Sets label coordinate for Vectorizer. By default it equals null and zero() will be used as label value.
      Parameters:
        `labelCoord` - Label coordinate.
      Returns:
        this.

    - #### labeled

          public Vectorizer<K,V,C,L> labeled(Vectorizer.LabelCoordinate labelCoord)

      Sets label coordinate for Vectorizer. By default it equals null and zero() will be used as label value.
      Parameters:
        `labelCoord` - Label coordinate.
      Returns:
        this.

    - #### exclude

          public Vectorizer<K,V,C,L> exclude(C... coords)

      Exclude these coordinates from result vector.
      Parameters:
        `coords` - Coordinates.
      Returns:
        this.

    - #### extract

          public LabeledVector<L> extract(K k,
                                          V v)

      Extract `LabeledVector` from key and value.
      Specified by:
        `extract` in interface `FeatureLabelExtractor<K,V,L>`
      Parameters:
        `k` - Key.
        `v` - Value.
      Returns:
        Labeled vector.

    - #### feature

          protected abstract Serializable feature(C coord,
                                                  K key,
                                                  V value)

      Extracts feature value by given coordinate.
      Parameters:
        `coord` - Coordinate.
        `key` - Key.
        `value` - Value.
      Returns:
        feature value.

    - #### label

          protected abstract L label(C coord,
                                     K key,
                                     V value)

      Extract label value by given coordinate.
      Parameters:
        `coord` - Coordinate.
        `key` - Key.
        `value` - Value.
      Returns:
        label value.

    - #### zero

          protected abstract L zero()

      Returns default label value for unlabeled data.
      Returns:
        label value.

    - #### allCoords

          protected abstract List<C> allCoords(K key,
                                               V value)

      Returns list of all coordinate with feature values.
      Parameters:
        `key` - Key.
        `value` - Value.
      Returns:
        all coordinates list.

    - #### createVector

          protected Vector createVector(int size)

      Create an instance of vector.
      Parameters:
        `size` - Vector size.
      Returns:
        vector.

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021