- 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.
This function calculates the overall error of a given program tree.
The error is calculated from the
LossFunction and, if desired, the
program Complexity.
final Error<Double> error = Error.of(LossFunction::mse, Complexity.ofNodeCount(50));
- Since:
- 5.0
- Version:
- 5.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondoubleCalculates the overall error of a given program tree.static <T> Error<T> of(LossFunction<T> loss) Creates an error function which only uses the givenlossfunction for calculating the program errorstatic <T> Error<T> of(LossFunction<T> loss, Complexity<T> complexity) Creates an error function by combining the givenlossfunction and programcomplexity.static <T> Error<T> of(LossFunction<T> loss, Complexity<T> complexity, DoubleBinaryOperator compose) Creates an error function by combining the givenlossfunction and programcomplexity.
-
Method Details
-
apply
Calculates the overall error of a given program tree. The error is calculated from theLossFunctionand, if desired, the programComplexity.- Parameters:
program- the program tree which calculated thecalculatedvaluescalculated- the calculated function valuesexpected- the expected function values- Returns:
- the overall program error
- Throws:
NullPointerException- if one of the arguments isnull
-
of
Creates an error function which only uses the givenlossfunction 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 givenlossfunction isnull
-
of
Creates an error function by combining the givenlossfunction and programcomplexity. The loss function and program complexity is combined in the following way:error = loss + loss*complexity. The complexity function penalizes programs which grow 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 givenlossfunction and programcomplexity. The loss function and program complexity is combined in the following way:error = loss + loss*complexity. The complexity function penalizes programs which grow to big.- Type Parameters:
T- the sample type- Parameters:
loss- the loss functioncomplexity- the program complexity measurecompose- the function which composes thelossandcomplexityfunction- Returns:
- a new error function by combining the given loss and complexity function
- Throws:
NullPointerException- if one of the functions isnull
-