Package org.tribuo

Class RealInfo

All Implemented Interfaces:
Serializable, Cloneable, VariableInfo
Direct Known Subclasses:
RealIDInfo

public class RealInfo extends SkeletalVariableInfo
Stores information about real valued features.

Contains sufficient statistics to model the feature as a gaussian, plus the max and min values.

Does not contain an id number, but can be transformed into RealIDInfo which does contain an id number.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double
    The maximum observed feature value.
    protected double
    The feature mean.
    protected double
    The minimum observed feature value.
    protected double
    The sum of the squared feature values (used to compute the variance).

    Fields inherited from class org.tribuo.SkeletalVariableInfo

    count, name
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Creates an empty real info with the supplied name.
     
    RealInfo(String name, int count)
    Creates a real info with the supplied starting conditions.
     
    RealInfo(String name, int count, double max, double min, double mean, double sumSquares)
    Creates a real info with the supplied starting conditions.
     
    Copy constructor.
    protected
    RealInfo(RealInfo other, String newName)
    Copy constructor which renames the feature.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a copy of this variable info.
    double
    Gets the maximum observed value.
    double
    Gets the sample mean.
    double
    Gets the minimum observed value.
    double
    Gets the sample variance.
    makeIDInfo(int id)
    Generates a VariableIDInfo subclass which represents the same feature.
    protected void
    observe(double value)
    Records the value.
    rename(String newName)
    Rename generates a fresh VariableInfo with the new name.
     
    double
    Sample a value uniformly from the range of this variable.

    Methods inherited from class org.tribuo.SkeletalVariableInfo

    equals, getCount, getName, hashCode

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • max

      protected double max
      The maximum observed feature value.
    • min

      protected double min
      The minimum observed feature value.
    • mean

      protected double mean
      The feature mean.
    • sumSquares

      protected double sumSquares
      The sum of the squared feature values (used to compute the variance).
  • Constructor Details

    • RealInfo

      public RealInfo(String name)
      Creates an empty real info with the supplied name.
      Parameters:
      name - The feature name.
    • RealInfo

      public RealInfo(String name, int count)
      Creates a real info with the supplied starting conditions.

      All observations are assumed to be of zero.

      Parameters:
      name - The feature name.
      count - The number of zeros observed.
    • RealInfo

      public RealInfo(String name, int count, double max, double min, double mean, double sumSquares)
      Creates a real info with the supplied starting conditions.
      Parameters:
      name - The feature name.
      count - The observation count.
      max - The maximum observed value.
      min - The minimum observed value.
      mean - The mean observed value.
      sumSquares - The sum of the squared values (used to calculate variance online).
    • RealInfo

      public RealInfo(RealInfo other)
      Copy constructor.
      Parameters:
      other - The info to copy.
    • RealInfo

      protected RealInfo(RealInfo other, String newName)
      Copy constructor which renames the feature. Used to redact the feature name.
      Parameters:
      other - The info to copy.
      newName - The new name.
  • Method Details

    • observe

      protected void observe(double value)
      Description copied from class: SkeletalVariableInfo
      Records the value.
      Overrides:
      observe in class SkeletalVariableInfo
      Parameters:
      value - The observed value.
    • getMin

      public double getMin()
      Gets the minimum observed value.
      Returns:
      The minimum value.
    • getMax

      public double getMax()
      Gets the maximum observed value.
      Returns:
      The maximum value.
    • getMean

      public double getMean()
      Gets the sample mean.
      Returns:
      The sample mean.
    • getVariance

      public double getVariance()
      Gets the sample variance.
      Returns:
      The sample variance.
    • copy

      public RealInfo copy()
      Description copied from interface: VariableInfo
      Returns a copy of this variable info.
      Returns:
      A copy.
    • makeIDInfo

      public RealIDInfo makeIDInfo(int id)
      Description copied from interface: VariableInfo
      Generates a VariableIDInfo subclass which represents the same feature.
      Parameters:
      id - The id number.
      Returns:
      A VariableInfo with the same information, plus the id.
    • rename

      public RealInfo rename(String newName)
      Description copied from interface: VariableInfo
      Rename generates a fresh VariableInfo with the new name. The name forms part of the hashcode so it's immutable in the object.
      Parameters:
      newName - The new name.
      Returns:
      A VariableInfo subclass with the new name.
    • uniformSample

      public double uniformSample(SplittableRandom rng)
      Description copied from interface: VariableInfo
      Sample a value uniformly from the range of this variable.
      Parameters:
      rng - The rng to use.
      Returns:
      A sample from this variable.
    • toString

      public String toString()
      Overrides:
      toString in class SkeletalVariableInfo