Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## cc.mallet.types
Class FeatureVector

    java.lang.Object
      cc.mallet.types.SparseVector
          cc.mallet.types.FeatureVector

All Implemented Interfaces:
  AlphabetCarrying, ConstantMatrix, Vector, java.io.Serializable

Direct Known Subclasses:
  AugmentableFeatureVector, Multinomial, RankedFeatureVector

    public class FeatureVector

extends SparseVector
implements java.io.Serializable, 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.

Author:
  Andrew McCallum mccallum@cs.umass.edu
See Also:
  `SparseVector`, `Alphabet`, Serialized Form

Field Summary

Fields inherited from class cc.mallet.types.SparseVector
`hasInfinite, indices, values`

Constructor Summary
`` | `FeatureVector(Alphabet dict, double[] values)` Create a dense vector
`` | `FeatureVector(Alphabet dict, int[] featureIndices)` Create binary vector
`` | `FeatureVector(Alphabet dict, int[] featureIndices, double[] values)` Create non-binary vector, possibly dense if "featureIndices" or possibly sparse, if not
`protected` | `FeatureVector(Alphabet dict, int[] indices, double[] values, int capacity, int size, boolean copy, boolean checkIndicesSorted, boolean removeDuplicates)`
`` | `FeatureVector(Alphabet dict, java.lang.Object[] keys, double[] values)`
`` | `FeatureVector(Alphabet dict, PropertyList pl, boolean binary)`
`` | `FeatureVector(Alphabet dict, PropertyList pl, boolean binary, boolean growAlphabet)`
`` | `FeatureVector(FeatureSequence fs)`
`` | `FeatureVector(FeatureSequence fs, boolean binary)`
`` | `FeatureVector(FeatureVector fv, Alphabet newVocab, FeatureSelection fsNarrow, FeatureSelection fsWide)`
`` | `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.

Method Summary
`boolean` | `alphabetsMatch(AlphabetCarrying object)`
`ConstantMatrix` | `cloneMatrix()` CLONING
`ConstantMatrix` | `cloneMatrixZeroed()`
`boolean` | `contains(java.lang.Object entry)`
`Alphabet` | `getAlphabet()`
`Alphabet[]` | `getAlphabets()`
`static int[]` | `getObjectIndices(java.lang.Object[] entries, Alphabet dict, boolean addIfNotPresent)`
`int` | `location(java.lang.Object entry)`
`static FeatureVector` | `newFeatureVector(FeatureVector fv, Alphabet newVocab, FeatureSelection fs)` Construct a new FeatureVector, selecting only those features in fs, and having new (presumably more compact, dense) Alphabet.
`boolean` | `toSimpFile(java.lang.String FileName, int curdocNo, boolean printcounts)`
`java.lang.String` | `toString()`
`java.lang.String` | `toString(boolean onOneLine)`
`double` | `value(java.lang.Object o)`

Methods inherited from class cc.mallet.types.SparseVector
`absNorm, addTo, addTo, arrayCopyFrom, arrayCopyFrom, arrayCopyInto, dotProduct, dotProduct, dotProduct, dotProduct, extendedDotProduct, extendedDotProduct, getDimensions, getIndices, getNumDimensions, getValues, incrementValue, indexAtLocation, infinityNorm, isBinary, isInfinite, isNaN, isNaNOrInfinite, location, makeBinary, makeNonBinary, map, numLocations, oneNorm, plusEqualsSparse, plusEqualsSparse, print, removeDuplicates, setAll, setValue, setValueAtLocation, singleIndex, singleSize, singleToIndices, singleValue, sortIndices, timesEquals, timesEqualsSparse, timesEqualsSparse, timesEqualsSparseZero, twoNorm, value, value, valueAtLocation, vectorAdd`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

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(FeatureSequence fs)

### FeatureVector

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

### FeatureVector

    public FeatureVector(Alphabet dict,
                         PropertyList pl,
                         boolean binary)

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

### FeatureVector

    public FeatureVector(FeatureVector fv,
                         Alphabet newVocab,
                         FeatureSelection fsNarrow,
                         FeatureSelection fsWide)

Method Detail

### getObjectIndices

    public static int[] getObjectIndices(java.lang.Object[] entries,
                                         Alphabet dict,
                                         boolean addIfNotPresent)

### newFeatureVector

    public static FeatureVector newFeatureVector(FeatureVector fv,
                                                 Alphabet newVocab,
                                                 FeatureSelection fs)

  Construct a new FeatureVector, selecting only those features in fs, and having new (presumably more compact, dense) Alphabet.

### cloneMatrix

    public ConstantMatrix cloneMatrix()

  Description copied from class: `SparseVector`
  CLONING

  Specified by:
    `cloneMatrix` in interface `ConstantMatrix`
  Overrides:
    `cloneMatrix` in class `SparseVector`

### cloneMatrixZeroed

    public ConstantMatrix cloneMatrixZeroed()

  Overrides:
    `cloneMatrixZeroed` in class `SparseVector`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `SparseVector`

### toSimpFile

    public boolean toSimpFile(java.lang.String FileName,
                              int curdocNo,
                              boolean printcounts)

### toString

    public java.lang.String toString(boolean onOneLine)

  Overrides:
    `toString` in class `SparseVector`

### getAlphabet

    public Alphabet getAlphabet()

  Specified by:
    `getAlphabet` in interface `AlphabetCarrying`

### getAlphabets

    public Alphabet[] getAlphabets()

  Specified by:
    `getAlphabets` in interface `AlphabetCarrying`

### alphabetsMatch

    public boolean alphabetsMatch(AlphabetCarrying object)

### location

    public int location(java.lang.Object entry)

### contains

    public boolean contains(java.lang.Object entry)

### value

    public double value(java.lang.Object o)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD