Class SimpleTransform

java.lang.Object
org.tribuo.transform.transformations.SimpleTransform
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<TransformationProvenance>, Serializable, Transformation, Transformer, TransformStatistics

public final class SimpleTransform extends Object implements Transformer, Transformation, TransformStatistics
This is used for stateless functions such as exp, log, addition or multiplication by a constant.

It's a Transformation, Transformer and TransformStatistics as it has no data dependent state. This means a single Transformer can be used for every feature in a dataset.

Wraps a DoubleUnaryOperator which actually performs the transformation.

See Also:
  • Field Details

    • EPSILON

      public static final double EPSILON
      Epsilon for determining when two double values are the same.
      See Also:
  • Method Details

    • postConfig

      public void postConfig()
      Used by the OLCUT configuration system, and should not be called by external code.
      Specified by:
      postConfig in interface com.oracle.labs.mlrg.olcut.config.Configurable
    • getProvenance

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

      public void observeValue(double value)
      No-op on this TransformStatistics.
      Specified by:
      observeValue in interface TransformStatistics
      Parameters:
      value - The value to observe
    • observeSparse

      @Deprecated public void observeSparse()
      Deprecated.
      No-op on this TransformStatistics.
      Specified by:
      observeSparse in interface TransformStatistics
    • observeSparse

      public void observeSparse(int count)
      No-op on this TransformStatistics.
      Specified by:
      observeSparse in interface TransformStatistics
      Parameters:
      count - The number of sparse values.
    • generateTransformer

      public Transformer generateTransformer()
      Returns itself.
      Specified by:
      generateTransformer in interface TransformStatistics
      Returns:
      this.
    • createStats

      public TransformStatistics createStats()
      Returns itself.
      Specified by:
      createStats in interface Transformation
      Returns:
      this.
    • transform

      public double transform(double input)
      Apply the operation to the input.
      Specified by:
      transform in interface Transformer
      Parameters:
      input - The input value to transform.
      Returns:
      The transformed value.
    • toString

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

      public static SimpleTransform exp()
      Generate a SimpleTransform that applies Math.exp(double).
      Returns:
      The exponential function.
    • log

      public static SimpleTransform log()
      Generate a SimpleTransform that applies Math.log(double).
      Returns:
      The logarithm function.
    • add

      public static SimpleTransform add(double operand)
      Generate a SimpleTransform that adds the operand to each value.
      Parameters:
      operand - The operand to add.
      Returns:
      An addition function.
    • sub

      public static SimpleTransform sub(double operand)
      Generate a SimpleTransform that subtracts the operand from each value.
      Parameters:
      operand - The operand to subtract.
      Returns:
      A subtraction function.
    • mul

      public static SimpleTransform mul(double operand)
      Generate a SimpleTransform that multiplies each value by the operand.
      Parameters:
      operand - The operand to multiply.
      Returns:
      A multiplication function.
    • div

      public static SimpleTransform div(double operand)
      Generate a SimpleTransform that divides each value by the operand.
      Parameters:
      operand - The divisor.
      Returns:
      A division function.
    • binarise

      public static SimpleTransform binarise()
      Generate a SimpleTransform that sets negative and zero values to zero and positive values to one.
      Returns:
      A binarising function.
    • threshold

      public static SimpleTransform threshold(double min, double max)
      Generate a SimpleTransform that sets values below min to min, and values above max to max.
      Parameters:
      min - The minimum value. To not threshold below, set to Double.NEGATIVE_INFINITY.
      max - The maximum value. To not threshold above, set to Double.POSITIVE_INFINITY.
      Returns:
      A thresholding function.