Class FeatureData

  • All Implemented Interfaces:
    com.yahoo.data.access.Inspectable, JsonProducer

    public class FeatureData
    extends Object
    implements com.yahoo.data.access.Inspectable, JsonProducer
    A wrapper for structured data representing feature values: A map of floats and tensors. This class is immutable but not thread safe.
    Author:
    bratseth
    • Constructor Detail

      • FeatureData

        public FeatureData​(com.yahoo.data.access.Inspector value)
    • Method Detail

      • inspect

        public com.yahoo.data.access.Inspector inspect()
        Returns the fields of this as an inspector, where tensors are represented as binary data which can be decoded using com.yahoo.tensor.serialization.TypedBinaryFormat.decode(Optional.empty(), GrowableByteBuffer.wrap(featureValue.asData()))
        Specified by:
        inspect in interface com.yahoo.data.access.Inspectable
      • toJson

        public String toJson()
        Description copied from interface: JsonProducer
        Convenience method equivalent to writeJson(new StringBuilder()).toString()
        Specified by:
        toJson in interface JsonProducer
        Returns:
        a String containing JSON representation of this object's data
      • toJson

        public String toJson​(boolean tensorShortForm)
      • writeJson

        public StringBuilder writeJson​(StringBuilder target)
        Description copied from interface: JsonProducer
        Append the JSON representation of this object's data to a StringBuilder.
        Specified by:
        writeJson in interface JsonProducer
        Parameters:
        target - the StringBuilder to append to
        Returns:
        the target passed in is also returned (to allow chaining)
      • getDouble

        public Double getDouble​(String featureName)
        Returns the value of a scalar feature, or null if it is not present.
        Throws:
        IllegalArgumentException - if the value exists but isn't a scalar (that is, if it is a tensor with nonzero rank)
      • getTensor

        public com.yahoo.tensor.Tensor getTensor​(String featureName)
        Returns the value of a tensor feature, or null if it is not present. This will return any feature value: Scalars are returned as a rank 0 tensor.
      • featureNames

        public Set<String> featureNames()
        Returns the names of the features available in this
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object