Package io.jenetics.prog.regression
Interface Error<T>
-
- Type Parameters:
T
- the sample type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Error<T>
This function calculates the overall error of a given program tree. The error is calculated from theLossFunction
and, if desired, the programComplexity
.final Error<Double> error = Error.of(LossFunction::mse, Complexity.ofNodeCount(50));
- Since:
- 5.0
- Version:
- 5.0
- See Also:
LossFunction
,Complexity
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description double
apply(Tree<? extends Op<T>,?> program, T[] calculated, T[] expected)
Calculates the overall error of a given program tree.static <T> Error<T>
of(LossFunction<T> loss)
Creates an error function which only uses the givenloss
function for calculating the program errorstatic <T> Error<T>
of(LossFunction<T> loss, Complexity<T> complexity)
Creates an error function by combining the givenloss
function and programcomplexity
.static <T> Error<T>
of(LossFunction<T> loss, Complexity<T> complexity, DoubleBinaryOperator compose)
Creates an error function by combining the givenloss
function and programcomplexity
.
-
-
-
Method Detail
-
apply
double apply(Tree<? extends Op<T>,?> program, T[] calculated, T[] expected)
Calculates the overall error of a given program tree. The error is calculated from theLossFunction
and, if desired, the programComplexity
.- Parameters:
program
- the program tree which calculated thecalculated
valuescalculated
- the calculated function valuesexpected
- the expected function values- Returns:
- the overall program error
- Throws:
NullPointerException
- if one of the arguments isnull
-
of
static <T> Error<T> of(LossFunction<T> loss)
Creates an error function which only uses the givenloss
function for calculating the program error- Type Parameters:
T
- the sample type- Parameters:
loss
- the loss function to use for calculating the program error- Returns:
- an error function which uses the loss function for error calculation
- Throws:
NullPointerException
- if the givenloss
function isnull
-
of
static <T> Error<T> of(LossFunction<T> loss, Complexity<T> complexity)
Creates an error function by combining the givenloss
function and programcomplexity
. The loss function and program complexity is combined in the following way:error = loss + loss*complexity
. The complexity function penalizes programs which grows to big.- Type Parameters:
T
- the sample type- Parameters:
loss
- the loss functioncomplexity
- the program complexity measure- Returns:
- a new error function by combining the given loss and complexity function
- Throws:
NullPointerException
- if one of the functions isnull
-
of
static <T> Error<T> of(LossFunction<T> loss, Complexity<T> complexity, DoubleBinaryOperator compose)
Creates an error function by combining the givenloss
function and programcomplexity
. The loss function and program complexity is combined in the following way:error = loss + loss*complexity
. The complexity function penalizes programs which grows to big.- Type Parameters:
T
- the sample type- Parameters:
loss
- the loss functioncomplexity
- the program complexity measurecompose
- the function which composes theloss
andcomplexity
function- Returns:
- a new error function by combining the given loss and complexity function
- Throws:
NullPointerException
- if one of the functions isnull
-
-