Package ciir.umass.edu.learning
Class SparseDataPoint
- java.lang.Object
-
- ciir.umass.edu.learning.DataPoint
-
- ciir.umass.edu.learning.SparseDataPoint
-
public class SparseDataPoint extends DataPoint
Implements a sparse data point using a compressed sparse row data structure- Author:
- Siddhartha Bagaria
-
-
Field Summary
-
Fields inherited from class ciir.umass.edu.learning.DataPoint
cached, description, FEATURE_INCREASE, fVals, id, knownFeatures, label, MAX_FEATURE, missingZero, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description SparseDataPoint(float[] fVals, int[] fIds, java.lang.String queryId, float relevanceLabel)Allows the direct allocation of a SparseDataPoint instead of having it parse text.SparseDataPoint(SparseDataPoint dp)SparseDataPoint(java.lang.String text)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatgetFeatureValue(int fid)Get the value of the feature with the given feature IDfloat[]getFeatureVector()Gets the value of all features as a dense array of feature values.booleanhasFeature(int fid)voidsetFeatureValue(int fid, float fval)Set the value of the feature with the given feature IDvoidsetFeatureVector(float[] dfVals)Sets the value of all features with the provided dense array of feature values-
Methods inherited from class ciir.umass.edu.learning.DataPoint
getCached, getDescription, getID, getKey, getLabel, getNumberOfKnownFeatures, getValue, isUnknown, parse, resetCached, setCached, setDescription, setID, setLabel, toString
-
-
-
-
Constructor Detail
-
SparseDataPoint
public SparseDataPoint(java.lang.String text)
-
SparseDataPoint
public SparseDataPoint(float[] fVals, int[] fIds, java.lang.String queryId, float relevanceLabel)Allows the direct allocation of a SparseDataPoint instead of having it parse text.
The fVals array represents the sparse feature values. Only non-null values must be specified.
The fIds array has equal length to fVals and specifies for each position the feature ID that this position in both array stands for. Thus, if fIds[1] == '5' then fVals[5] is the value of this data point for feature number 5. The values in fIds must be sorted ascendingly.
- Parameters:
fVals- The feature values, starting at index 0.fIds- The feature IDs, starting at index 0.queryId- The ID of the query this datapoint is associated with.relevanceLabel- The relevance label of this datapoint with respect to the query.
-
SparseDataPoint
public SparseDataPoint(SparseDataPoint dp)
-
-
Method Detail
-
hasFeature
public boolean hasFeature(int fid)
-
getFeatureValue
public float getFeatureValue(int fid)
Description copied from class:DataPointGet the value of the feature with the given feature ID- Specified by:
getFeatureValuein classDataPoint- Returns:
-
setFeatureValue
public void setFeatureValue(int fid, float fval)Description copied from class:DataPointSet the value of the feature with the given feature ID- Specified by:
setFeatureValuein classDataPoint
-
getFeatureVector
public float[] getFeatureVector()
Description copied from class:DataPointGets the value of all features as a dense array of feature values.- Specified by:
getFeatureVectorin classDataPoint
-
setFeatureVector
public void setFeatureVector(float[] dfVals)
Description copied from class:DataPointSets the value of all features with the provided dense array of feature values- Specified by:
setFeatureVectorin classDataPoint
-
-