- 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.
Represents a complexity measure if a given program tree. The
program complexity ensures that simpler programs with similar loss function
values are preferred. It is part of the overall
Error
function.
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 complexity of the current program (possibly) relative to the actual error value.static double
This method uses the node count of a program tree for calculating its complexity.static <T> Complexity
<T> ofNodeCount
(int maxNodeCount) Return a complexity measure which counts the number of nodes of a program.
-
Method Details
-
apply
Calculates the complexity of the current program (possibly) relative to the actual error value.- Parameters:
program
- the actual program- Returns:
- the measure of the program complexity
-
ofNodeCount
Return a complexity measure which counts the number of nodes of a program.- Type Parameters:
T
- the sample type- Parameters:
maxNodeCount
- the maximal node count. The returned complexity will be one of the program node count is greater or equal the givencount
- Returns:
- a program node count complexity measure
- Throws:
IllegalArgumentException
- if the max nodecount
is smaller than one- See Also:
-
count
This method uses the node count of a program tree for calculating its complexity. The returned node count measure is within the range of[0, 1]
. If the program contains only one node, zero is returned. If the node count is bigger or equalmaxNodes
, one is returned.The complexity is calculated in the following way:
final double cc = min(program.size() - 1, maxNodes); return 1.0 - sqrt(1.0 - (cc*cc)/(maxNodes*maxNodes));
- Parameters:
program
- the program used for the complexity measuremaxNodes
- the maximal expected node count- Returns:
- the complexity measure of the given
program
- Throws:
NullPointerException
- if the givenprogram
isnull
IllegalArgumentException
- ifmaxNodes
is smaller than one- See Also:
-