Class Regressor.DimensionTuple

java.lang.Object
org.tribuo.regression.Regressor
org.tribuo.regression.Regressor.DimensionTuple
All Implemented Interfaces:
Serializable, Iterable<Regressor.DimensionTuple>, Output<Regressor>, ProtoSerializable<org.tribuo.protos.core.OutputProto>
Enclosing class:
Regressor

public static final class Regressor.DimensionTuple extends Regressor
A Regressor which contains a single dimension, used internally when the model implementation doesn't natively support multi-dimensional regression outputs.
See Also:
  • Constructor Details

    • DimensionTuple

      public DimensionTuple(String name, double value, double variance)
      Creates a dimension tuple from the supplied name, value and variance.
      Parameters:
      name - The dimension name.
      value - The dimension value.
      variance - The variance of the value, if known. Otherwise Double.NaN.
    • DimensionTuple

      public DimensionTuple(String name, double value)
      Creates a dimension tuple from the supplied name and value. Sets the variance to Double.NaN.
      Parameters:
      name - The dimension name.
      value - The dimension value.
  • Method Details

    • deserializeFromProto

      public static Regressor.DimensionTuple 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.
    • size

      public int size()
      Description copied from class: Regressor
      Returns the number of dimensions in this regressor.
      Overrides:
      size in class Regressor
      Returns:
      The number of dimensions.
    • toString

      public String toString()
      Overrides:
      toString in class Regressor
    • getDimension

      public Optional<Regressor.DimensionTuple> getDimension(String name)
      Description copied from class: Regressor
      Returns a dimension tuple for the requested dimension, or optional empty if it's not valid.
      Overrides:
      getDimension in class Regressor
      Parameters:
      name - The dimension name.
      Returns:
      A tuple representing that dimension.
    • iterator

      public Iterator<Regressor.DimensionTuple> iterator()
      Specified by:
      iterator in interface Iterable<Regressor.DimensionTuple>
      Overrides:
      iterator in class Regressor
    • copy

      public Regressor.DimensionTuple copy()
      Description copied from interface: Output
      Deep copy of the output up to its immutable state.
      Specified by:
      copy in interface Output<Regressor>
      Overrides:
      copy in class Regressor
      Returns:
      A copy of the output.
    • getName

      public String getName()
      Returns the name.
      Returns:
      The name.
    • getValue

      public double getValue()
      Returns the value.
      Returns:
      The value.
    • getVariance

      public double getVariance()
      Returns the variance.
      Returns:
      The variance.
    • getSerializableForm

      public String getSerializableForm(boolean includeConfidence)
      Description copied from interface: Output
      Generates a String suitable for writing to a csv or json file.
      Specified by:
      getSerializableForm in interface Output<Regressor>
      Overrides:
      getSerializableForm in class Regressor
      Parameters:
      includeConfidence - Include whatever confidence score the label contains, if known.
      Returns:
      A String representation of this Output.
    • fullEquals

      public boolean fullEquals(Regressor other)
      Description copied from interface: Output
      Compares other to this output. Uses all score values and the strings.
      Specified by:
      fullEquals in interface Output<Regressor>
      Overrides:
      fullEquals in class Regressor
      Parameters:
      other - Another output instance.
      Returns:
      True if the other instance has value equality to this instance. False otherwise.
    • equals

      public boolean equals(Object o)
      Description copied from class: Regressor
      Regressors are equal if they have the same number of dimensions and equal dimension names.
      Overrides:
      equals in class Regressor
      Parameters:
      o - An object.
      Returns:
      True if Object is a Regressor with the same dimension names, false otherwise.
    • hashCode

      public int hashCode()
      All regressors have a hashcode based on only the dimension names.
      Overrides:
      hashCode in class Regressor
      Returns:
      A hashcode.
    • getDimensionNamesString

      public String getDimensionNamesString()
      Description copied from class: Regressor
      Returns a comma separated list of the dimension names.
      Overrides:
      getDimensionNamesString in class Regressor
      Returns:
      The dimension names comma separated.
    • serialize

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