Class FeatureVector

  • All Implemented Interfaces:
    AlphabetCarrying, ConstantMatrix, Vector,
    Direct Known Subclasses:
    AugmentableFeatureVector, Multinomial, RankedFeatureVector

    public class FeatureVector
    extends SparseVector
    implements, AlphabetCarrying
    A subset of an Alphabet in which each element of the subset has an associated value. The subset is represented as a SparseVector

    A SparseVector represents only the non-zero locations of a vector. In the case of a FeatureVector, a location represents the index of an entry in the Alphabet that is contained in the FeatureVector.

    To loop over the elements of a feature vector, one loops over the consecutive integers between 0 and the number of locations in the feature vector. From these locations one can cheaply obtain the index of the entry in the underlying Alphabet, the entry itself, and the value in this feature vector associated the entry.

    A SparseVector (or FeatureVector) can be sparse or dense depending on whether or not an array if indices is specified at construction time. If the FeatureVector is dense, the mapping from location to index is the identity mapping.

    The associated value of an element in a SparseVector (or FeatureVector) can be a double or binary (0.0 or 1.0), depending on whether an array of doubles is specified at contruction time.

    Andrew McCallum
    See Also:
    SparseVector, Alphabet, Serialized Form
    • Constructor Detail

      • FeatureVector

        protected FeatureVector​(Alphabet dict,
                                int[] indices,
                                double[] values,
                                int capacity,
                                int size,
                                boolean copy,
                                boolean checkIndicesSorted,
                                boolean removeDuplicates)
      • FeatureVector

        public FeatureVector​(Alphabet dict,
                             double[] values)
        Create a dense vector
      • FeatureVector

        public FeatureVector​(Alphabet dict,
                             int[] featureIndices,
                             double[] values)
        Create non-binary vector, possibly dense if "featureIndices" or possibly sparse, if not
      • FeatureVector

        public FeatureVector​(Alphabet dict,
                             int[] featureIndices)
        Create binary vector
      • FeatureVector

        public FeatureVector​(Alphabet dict,
                             java.lang.Object[] keys,
                             double[] values)
      • FeatureVector

        public FeatureVector​(FeatureSequence fs,
                             boolean binary)
      • FeatureVector

        public FeatureVector​(Alphabet dict,
                             PropertyList pl,
                             boolean binary,
                             boolean growAlphabet)
      • FeatureVector

        public FeatureVector​(FeatureVector fv,
                             Alphabet newVocab,
                             int[] conjunctions)
        New feature vector containing all the features of "fv", plus new features created by making conjunctions between the features in "conjunctions" and all the other features.