Package com.apple.foundationdb.kmeans
Interface KMeans.SizePenalty
- Enclosing class:
KMeans
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Soft size-balancing penalty hook.
fit multiplies the value returned by this
function by lambda and adds it to the per-pair base objective during the
assignment step, biasing the algorithm away from oversized clusters.
Pass lambda == 0 (or sizePenalty == null) to disable balancing.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondoublepenalty(int projectedSize, int targetSize) Implementation of penalty function.
-
Method Details
-
penalty
double penalty(int projectedSize, int targetSize) Implementation of penalty function.- Parameters:
projectedSize- the projected size of the candidate cluster after hypothetically assigning the current vector to ittargetSize- the target cluster size,n / k- Returns:
- a non-negative penalty; larger values discourage assignment to the cluster
-