|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cc.mallet.types.SparseVector cc.mallet.types.FeatureVector
public class FeatureVector
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.
SparseVector
,
Alphabet
,
Serialized FormField 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 |
---|
protected FeatureVector(Alphabet dict, int[] indices, double[] values, int capacity, int size, boolean copy, boolean checkIndicesSorted, boolean removeDuplicates)
public FeatureVector(Alphabet dict, double[] values)
public FeatureVector(Alphabet dict, int[] featureIndices, double[] values)
public FeatureVector(Alphabet dict, int[] featureIndices)
public FeatureVector(Alphabet dict, java.lang.Object[] keys, double[] values)
public FeatureVector(FeatureSequence fs, boolean binary)
public FeatureVector(FeatureSequence fs)
public FeatureVector(Alphabet dict, PropertyList pl, boolean binary, boolean growAlphabet)
public FeatureVector(Alphabet dict, PropertyList pl, boolean binary)
public FeatureVector(FeatureVector fv, Alphabet newVocab, int[] conjunctions)
public FeatureVector(FeatureVector fv, Alphabet newVocab, FeatureSelection fsNarrow, FeatureSelection fsWide)
Method Detail |
---|
public static int[] getObjectIndices(java.lang.Object[] entries, Alphabet dict, boolean addIfNotPresent)
public static FeatureVector newFeatureVector(FeatureVector fv, Alphabet newVocab, FeatureSelection fs)
public ConstantMatrix cloneMatrix()
SparseVector
cloneMatrix
in interface ConstantMatrix
cloneMatrix
in class SparseVector
public ConstantMatrix cloneMatrixZeroed()
cloneMatrixZeroed
in class SparseVector
public java.lang.String toString()
toString
in class SparseVector
public boolean toSimpFile(java.lang.String FileName, int curdocNo, boolean printcounts)
public java.lang.String toString(boolean onOneLine)
toString
in class SparseVector
public Alphabet getAlphabet()
getAlphabet
in interface AlphabetCarrying
public Alphabet[] getAlphabets()
getAlphabets
in interface AlphabetCarrying
public boolean alphabetsMatch(AlphabetCarrying object)
public int location(java.lang.Object entry)
public boolean contains(java.lang.Object entry)
public double value(java.lang.Object o)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |