Package org.tribuo

Class SelectedFeatureSet

java.lang.Object
org.tribuo.SelectedFeatureSet
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.provenance.Provenancable<FeatureSetProvenance>, Serializable, ProtoSerializable<org.tribuo.protos.core.FeatureSetProto>

public final class SelectedFeatureSet extends Object implements ProtoSerializable<org.tribuo.protos.core.FeatureSetProto>, com.oracle.labs.mlrg.olcut.provenance.Provenancable<FeatureSetProvenance>, Serializable
A record-like class for a selected feature set.

Uses record style accessors as it may be refactored into a record one day.

See Also:
  • Field Details

    • CURRENT_VERSION

      public static final int CURRENT_VERSION
      Protobuf serialization version.
      See Also:
  • Constructor Details

    • SelectedFeatureSet

      public SelectedFeatureSet(List<String> featureNames, List<Double> featureScores, boolean isOrdered, FeatureSetProvenance provenance)
      Create a selected feature set.
      Parameters:
      featureNames - The feature names.
      featureScores - The feature scores.
      isOrdered - Is this feature set ordered?
      provenance - The provenance of the feature selection.
  • Method Details

    • deserializeFromProto

      public static SelectedFeatureSet deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException
      Deserialization factory.
      Parameters:
      version - The serialized object version.
      className - The class name.
      message - The serialized data.
      Returns:
      The deserialized object.
      Throws:
      com.google.protobuf.InvalidProtocolBufferException - If the protobuf could not be parsed from the message.
    • featureNames

      public List<String> featureNames()
      The selected feature names in a possibly ordered list.
      Returns:
      The selected feature names.
    • featureScores

      public List<Double> featureScores()
      The selected feature scores in a possibly ordered list.

      If the algorithm did not produce scores then these values are all Double.NaN.

      Returns:
      The selected feature scores.
    • provenance

      public FeatureSetProvenance provenance()
      The provenance of the feature set.
      Returns:
      The feature set provenance.
    • getProvenance

      public FeatureSetProvenance getProvenance()
      Specified by:
      getProvenance in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<FeatureSetProvenance>
    • isOrdered

      public boolean isOrdered()
      Is this feature set ordered?
      Returns:
      True if the set is ordered.
    • serialize

      public org.tribuo.protos.core.FeatureSetProto serialize()
      Description copied from interface: ProtoSerializable
      Serializes this object to a protobuf.
      Specified by:
      serialize in interface ProtoSerializable<org.tribuo.protos.core.FeatureSetProto>
      Returns:
      The protobuf.
    • equals

      public boolean equals(Object o)
      Checks if this SelectedFeatureSet is equal to the supplied object.

      Equals is defined as containing the same features, in the same order, with the same scores, and with the same provenance information. As that provenance includes machine information and timestamps, this means equals is defined as did this object derive from the same computation as the supplied object.

      Overrides:
      equals in class Object
      Parameters:
      o - The object to test.
      Returns:
      True if they are equal.
    • hashCode

      public int hashCode()
      Computes the hash code.

      The hash code depends on the provenance object, and is not just a function of the feature names and scores, to be consistent with the definition of equals.

      Overrides:
      hashCode in class Object
      Returns:
      The hash code.
    • toString

      public String toString()
      Overrides:
      toString in class Object