- 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 TypeMethodDescriptiondouble
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 Details
-
apply
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
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
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 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 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 grow 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
-