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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Operations understood by this Transformation.static final class
Provenance forSimpleTransform
. -
Field Summary
Modifier and TypeFieldDescriptionstatic final double
Epsilon for determining when two double values are the same. -
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleTransform
add
(double operand) Generate a SimpleTransform that adds the operand to each value.static SimpleTransform
binarise()
Generate a SimpleTransform that sets negative and zero values to zero and positive values to one.Returns itself.static SimpleTransform
div
(double operand) Generate a SimpleTransform that divides each value by the operand.static SimpleTransform
exp()
Generate a SimpleTransform that appliesMath.exp(double)
.Returns itself.static SimpleTransform
log()
Generate a SimpleTransform that appliesMath.log(double)
.static SimpleTransform
mul
(double operand) Generate a SimpleTransform that multiplies each value by the operand.void
Deprecated.void
observeSparse
(int count) No-op on this TransformStatistics.void
observeValue
(double value) No-op on this TransformStatistics.void
Used by the OLCUT configuration system, and should not be called by external code.static SimpleTransform
sub
(double operand) Generate a SimpleTransform that subtracts the operand from each value.static SimpleTransform
threshold
(double min, double max) Generate a SimpleTransform that sets values below min to min, and values above max to max.toString()
double
transform
(double input) Apply the operation to the input.
-
Field Details
-
EPSILON
public static final double EPSILONEpsilon 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 interfacecom.oracle.labs.mlrg.olcut.config.Configurable
-
getProvenance
- Specified by:
getProvenance
in interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<TransformationProvenance>
-
observeValue
public void observeValue(double value) No-op on this TransformStatistics.- Specified by:
observeValue
in interfaceTransformStatistics
- Parameters:
value
- The value to observe
-
observeSparse
Deprecated.No-op on this TransformStatistics.- Specified by:
observeSparse
in interfaceTransformStatistics
-
observeSparse
public void observeSparse(int count) No-op on this TransformStatistics.- Specified by:
observeSparse
in interfaceTransformStatistics
- Parameters:
count
- The number of sparse values.
-
generateTransformer
Returns itself.- Specified by:
generateTransformer
in interfaceTransformStatistics
- Returns:
- this.
-
createStats
Returns itself.- Specified by:
createStats
in interfaceTransformation
- Returns:
- this.
-
transform
public double transform(double input) Apply the operation to the input.- Specified by:
transform
in interfaceTransformer
- Parameters:
input
- The input value to transform.- Returns:
- The transformed value.
-
toString
-
exp
Generate a SimpleTransform that appliesMath.exp(double)
.- Returns:
- The exponential function.
-
log
Generate a SimpleTransform that appliesMath.log(double)
.- Returns:
- The logarithm function.
-
add
Generate a SimpleTransform that adds the operand to each value.- Parameters:
operand
- The operand to add.- Returns:
- An addition function.
-
sub
Generate a SimpleTransform that subtracts the operand from each value.- Parameters:
operand
- The operand to subtract.- Returns:
- A subtraction function.
-
mul
Generate a SimpleTransform that multiplies each value by the operand.- Parameters:
operand
- The operand to multiply.- Returns:
- A multiplication function.
-
div
Generate a SimpleTransform that divides each value by the operand.- Parameters:
operand
- The divisor.- Returns:
- A division function.
-
binarise
Generate a SimpleTransform that sets negative and zero values to zero and positive values to one.- Returns:
- A binarising function.
-
threshold
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 toDouble.NEGATIVE_INFINITY
.max
- The maximum value. To not threshold above, set toDouble.POSITIVE_INFINITY
.- Returns:
- A thresholding function.
-