Package io.jenetics.prog.regression
Interface LossFunction<T>
-
- 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 LossFunction<T>
This function evaluates how well an evolved program tree fits the given sample data set. If the predictions are totally off, the loss function will output a higher value. If they’re pretty good, it’ll output a lower number. It is the essential part of the overallErrorfunction.final Error<Double> error = Error.of(LossFunction::mse);- Since:
- 5.0
- Version:
- 5.0
- Author:
- Franz Wilhelmstötter
- See Also:
- Loss function
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description doubleapply(T[] calculated, T[] expected)Calculates the error between the expected function values and the values calculated by the actualProgramGene.static doublemae(Double[] calculated, Double[] expected)Mean absolute error is measured as the average of sum of absolute differences between predictions and actual observations.static doublemse(Double[] calculated, Double[] expected)Mean square error is measured as the average of squared difference between predictions and actual observations.static doublermse(Double[] calculated, Double[] expected)Root mean square error is measured as the average of squared difference between predictions and actual observations.
-
-
-
Method Detail
-
apply
double apply(T[] calculated, T[] expected)
Calculates the error between the expected function values and the values calculated by the actualProgramGene.- Parameters:
calculated- the currently calculated function valueexpected- the expected function values- Returns:
- the error value
- Throws:
IllegalArgumentException- if the length of the two arrays are not equalNullPointerException- if one of thedouble[]arrays isnull
-
mse
static double mse(Double[] calculated, Double[] expected)
Mean square error is measured as the average of squared difference between predictions and actual observations.- Parameters:
calculated- the function values calculated with the current program treeexpected- the expected function value as given by the sample points- Returns:
- the mean square error
- Throws:
IllegalArgumentException- if the length of the two arrays are not equalNullPointerException- if one of thedouble[]arrays isnull- See Also:
rmse(Double[], Double[])
-
rmse
static double rmse(Double[] calculated, Double[] expected)
Root mean square error is measured as the average of squared difference between predictions and actual observations.- Parameters:
calculated- the function values calculated with the current program treeexpected- the expected function value as given by the sample points- Returns:
- the mean square error
- Throws:
IllegalArgumentException- if the length of the two arrays are not equalNullPointerException- if one of thedouble[]arrays isnull- See Also:
mse(Double[], Double[])
-
mae
static double mae(Double[] calculated, Double[] expected)
Mean absolute error is measured as the average of sum of absolute differences between predictions and actual observations.- Parameters:
calculated- the function values calculated with the current program treeexpected- the expected function value as given by the sample points- Returns:
- the mean absolute error
- Throws:
IllegalArgumentException- if the length of the two arrays are not equalNullPointerException- if one of thedouble[]arrays isnull
-
-