contextFold.features
Class SparseFeatureVector
java.lang.Object
contextFold.features.AbstractFeatureVector
contextFold.features.SparseFeatureVector
- All Implemented Interfaces:
- Dotable<AbstractFeatureVector>, java.io.Serializable
public class SparseFeatureVector
- extends AbstractFeatureVector
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
SparseFeatureVector
public SparseFeatureVector()
SparseFeatureVector
public SparseFeatureVector(AbstractFeatureVector toCopy)
getFeatureWeight
public float getFeatureWeight(int featureIx)
- Specified by:
getFeatureWeight
in class AbstractFeatureVector
- Parameters:
featureIx
- an index of a feature.
- Returns:
- the weight of the feature which index is
featureIx
.
getNonZeroFeatures
public java.util.Iterator<java.lang.Integer> getNonZeroFeatures()
- Specified by:
getNonZeroFeatures
in class AbstractFeatureVector
- Returns:
- an Iterator over the indices of features which weights
are not zero.
setFeatureWeight
public void setFeatureWeight(int featureIx,
float newFeatureWeight)
- Description copied from class:
AbstractFeatureVector
- Sets the weight of a given feature.
- Specified by:
setFeatureWeight
in class AbstractFeatureVector
- Parameters:
featureIx
- an index of a feature.newFeatureWeight
- a value to be set as the weight of
the feature which index is featureIx
.
clear
public void clear()
- Description copied from class:
AbstractFeatureVector
- Sets all weights to 0.
- Specified by:
clear
in class AbstractFeatureVector
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
toString
public java.lang.String toString(AbstractFeatureVector weights)
toString
public java.lang.String toString(AbstractFeatureVector weights,
boolean printColumn)
norm
public float norm()
- Specified by:
norm
in class AbstractFeatureVector
- Returns:
- the L_2 norm of the vector.
countNonZeroEntries
public int countNonZeroEntries()
- Specified by:
countNonZeroEntries
in class AbstractFeatureVector
- Returns:
- the number of features which weights are
not 0.