Class Vectors


  • public final class Vectors
    extends Object
    Utilities for mapping bags-of-words to real-valued vectors.
    See Also:
    Dot products
    • Method Detail

      • transform

        public static <V> org.apache.commons.math3.linear.RealVector transform​(Map<V,​Number> bag)
        Transform the bag-of-words into a real-valued vector.

        The number of elements in the vector is equal to the size of the key set of the given bag.

        Type Parameters:
        V - the type of bag elements
        Parameters:
        bag - the bag-of-words
        Returns:
        a real-valued vector
      • transform

        public static <V> org.apache.commons.math3.linear.RealVector transform​(Map<V,​Number> bag,
                                                                               Collection<V> domain)
        Transform the bag-of-words into a real-valued vector.

        The number of elements in the vector is equal to the size of the domain set.

        Please make sure that all elements in domain are unique.

        Type Parameters:
        V - the type of bag elements
        Parameters:
        bag - the bag-of-words
        domain - the collection of allowed elements of bag
        Returns:
        a real-valued vector