Class ImmutableRegressionInfo

java.lang.Object
org.tribuo.regression.RegressionInfo
org.tribuo.regression.ImmutableRegressionInfo
All Implemented Interfaces:
Serializable, Iterable<com.oracle.labs.mlrg.olcut.util.Pair<Integer,Regressor>>, ImmutableOutputInfo<Regressor>, OutputInfo<Regressor>, ProtoSerializable<org.tribuo.protos.core.OutputDomainProto>

public class ImmutableRegressionInfo extends RegressionInfo implements ImmutableOutputInfo<Regressor>
See Also:
  • Method Details

    • deserializeFromProto

      public static ImmutableRegressionInfo 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.
    • serialize

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

      public Set<Regressor> getDomain()
      Description copied from class: RegressionInfo
      Returns a set containing a Regressor for each dimension with the minimum value observed.
      Specified by:
      getDomain in interface OutputInfo<Regressor>
      Overrides:
      getDomain in class RegressionInfo
      Returns:
      A set of Regressors, each with one active dimension.
    • getID

      public int getID(Regressor output)
      Description copied from interface: ImmutableOutputInfo
      Return the id number associated with this output, or -1 if the output is unknown.
      Specified by:
      getID in interface ImmutableOutputInfo<Regressor>
      Parameters:
      output - An output
      Returns:
      A non-negative integer if the output is known, or -1 if the output is unknown.
    • getOutput

      public Regressor getOutput(int id)
      Description copied from interface: ImmutableOutputInfo
      Returns the output associated with this id, or null if the id is unknown.
      Specified by:
      getOutput in interface ImmutableOutputInfo<Regressor>
      Parameters:
      id - A non-negative integer.
      Returns:
      An output object or null if it's unknown.
    • getMin

      public double getMin(int id)
      Gets the minimum value this RegressionInfo has seen for that id.
      Parameters:
      id - The dimension to check.
      Returns:
      The minimum value for that dimension.
    • getMax

      public double getMax(int id)
      Gets the maximum value this RegressionInfo has seen for that id.
      Parameters:
      id - The dimension to check.
      Returns:
      The maximum value for that dimension.
    • getMean

      public double getMean(int id)
      Gets the mean value this RegressionInfo has seen for that id.
      Parameters:
      id - The dimension to check.
      Returns:
      The mean value for that dimension.
    • getVariance

      public double getVariance(int id)
      Gets the variance this RegressionInfo has seen for that id.
      Parameters:
      id - The dimension to check.
      Returns:
      The variance for that dimension.
    • getTotalObservations

      public long getTotalObservations()
      Description copied from interface: ImmutableOutputInfo
      Returns the total number of observed outputs seen by this ImmutableOutputInfo.
      Specified by:
      getTotalObservations in interface ImmutableOutputInfo<Regressor>
      Returns:
      The number of observed outputs.
    • copy

      public ImmutableRegressionInfo copy()
      Description copied from interface: OutputInfo
      Generates a copy of this OutputInfo, including it's mutability.
      Specified by:
      copy in interface OutputInfo<Regressor>
      Specified by:
      copy in class RegressionInfo
      Returns:
      A copy of the OutputInfo.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • validateMapping

      public boolean validateMapping()
      Returns true if the id numbers correspond to a lexicographic ordering of the dimension names starting from zero, false otherwise.
      Returns:
      True if the id mapping corresponds to lexicographic ordering of the names.
    • getIDtoNaturalOrderMapping

      public int[] getIDtoNaturalOrderMapping()
      Computes the mapping between ID numbers and regressor dimension indices.

      In some situations the regressor dimension ID numbers may not use the natural ordering (i.e., the lexicographic order of the dimension names). This method computes the mapping from the id numbers to the natural ordering.

      Returns:
      An array where arr[id] = natural_idx.
    • getNaturalOrderToIDMapping

      public int[] getNaturalOrderToIDMapping()
      Computes the mapping between regressor dimension indices and ID numbers.

      In some situations the regressor dimension ID numbers may not use the natural ordering (i.e., the lexicographic order of the dimension names). This method computes the mapping from the natural ordering to the id numbers.

      Returns:
      An array where arr[natural_idx] = id.
    • toReadableString

      public String toReadableString()
      Description copied from interface: OutputInfo
      Generates a String form of this OutputInfo.

      This String can contain newlines, tabs and other formatting.

      Specified by:
      toReadableString in interface OutputInfo<Regressor>
      Returns:
      A formatted String representing this OutputInfo.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • iterator

      public Iterator<com.oracle.labs.mlrg.olcut.util.Pair<Integer,Regressor>> iterator()
      Specified by:
      iterator in interface Iterable<com.oracle.labs.mlrg.olcut.util.Pair<Integer,Regressor>>
    • domainAndIDEquals

      public boolean domainAndIDEquals(ImmutableOutputInfo<Regressor> other)
      Description copied from interface: ImmutableOutputInfo
      Checks if the domain is the same as the other output info's domain, and that each element is mapped to the same id number.

      Note the default behaviour will be removed in a future major release, and should be overridden for performance reasons in all implementing classes.

      Specified by:
      domainAndIDEquals in interface ImmutableOutputInfo<Regressor>
      Parameters:
      other - The output info to compare.
      Returns:
      True if the domains and ids are the same.