Class SparseDataPoint


  • public class SparseDataPoint
    extends DataPoint
    Implements a sparse data point using a compressed sparse row data structure
    Author:
    Siddhartha Bagaria
    • 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.
    • Method Detail

      • hasFeature

        public boolean hasFeature​(int fid)
      • getFeatureValue

        public float getFeatureValue​(int fid)
        Description copied from class: DataPoint
        Get the value of the feature with the given feature ID
        Specified by:
        getFeatureValue in class DataPoint
        Returns:
      • setFeatureValue

        public void setFeatureValue​(int fid,
                                    float fval)
        Description copied from class: DataPoint
        Set the value of the feature with the given feature ID
        Specified by:
        setFeatureValue in class DataPoint
      • getFeatureVector

        public float[] getFeatureVector()
        Description copied from class: DataPoint
        Gets the value of all features as a dense array of feature values.
        Specified by:
        getFeatureVector in class DataPoint
      • setFeatureVector

        public void setFeatureVector​(float[] dfVals)
        Description copied from class: DataPoint
        Sets the value of all features with the provided dense array of feature values
        Specified by:
        setFeatureVector in class DataPoint