Record Class PartitionEvaluator.Parameters
- Record Components:
distanceEstimator- the distance estimator used for all distance computationsminRelativeSseGain- minimum relative SSE (sum of squared errors) improvement required; candidates with less improvement are rejected. May be negative if the caller wants to accept some SSE increase (e.g. for merges).minSeparation- minimum inter-cluster separation required; not checked when the candidate has fewer than two clustersmaxLowMarginRate- maximum fraction of vectors with low assignment margin; not checked when the candidate has fewer than two clustersminChildFraction- minimum fraction of vectors in the candidate's smallest cluster; candidates that violate this are reported asPartitionEvaluator.Decision.INVALID_CANDIDATE. This is the only balance threshold that can invalidate a candidate outright, so callers that must always have some admissible candidate should keep it low. Use0.0to disable.maxRelativeImbalance- maximumPartitionEvaluator.PartitionStats.relativeImbalance()the candidate may have, in[0, 1]; candidates that violate this are reported asPartitionEvaluator.Decision.KEEP_CURRENT. Use1.0to disable this check.lowMarginThreshold- distance threshold below which a vector's assignment margin is considered "low"; if non-positive, a metric-dependent default is used (0.02 for cosine, 5% of p95 for L2)alphaSseGain- weight for the SSE gain component in the composite scorebetaSeparationGain- weight for the separation gain component in the composite scoregammaImbalancePenalty- weight for the imbalance penalty in the composite scoredeltaLowMarginPenalty- weight for the low-margin-rate penalty in the composite scoreminScoreGain- minimum composite score improvement the candidate must achieve over the current partitioning to be accepted
- Enclosing class:
PartitionEvaluator
Balance is policed by two thresholds that deliberately measure different things.
minChildFraction is a plain fraction because it stands in for an absolute vector count â "do not
produce a cluster too small to be worth having" â and the population being partitioned does not depend on
k. maxRelativeImbalance is normalized by k because spread does: the worst achievable
PartitionEvaluator.PartitionStats.imbalance() is (kâ1)/k, so only the rescaled
PartitionEvaluator.PartitionStats.relativeImbalance() means the same thing at every k.
Both are safe for a single-cluster candidate without special-casing by the caller: smallestFrac is
1.0 and relativeImbalance() is 0, so a merge to one cluster passes any setting of
either. That is what makes a fallback merge structurally immune to the balance gates.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault weight of the SSE-gain term in the composite score.static final doubleDefault weight of the separation-gain term in the composite score.static final doubleDefault weight of the low-margin-penalty term in the composite score.static final doubleDefault weight of the imbalance-penalty term in the composite score.static final doubleSentinel selecting the metric-dependent low-margin threshold.static final doubleDefault ceiling on the fraction of vectors sitting near a cluster boundary.static final doubleDefault ceiling onPartitionEvaluator.PartitionStats.relativeImbalance();1.0disables the check.static final doubleDefault floor on the smallest cluster's share; seeminChildFraction().static final doubleDefault minimum relative SSE improvement a candidate must show.static final doubleDefault minimum composite score improvement required to accept a candidate.static final doubleDefault inter-cluster separation floor. -
Constructor Summary
ConstructorsConstructorDescriptionParameters(DistanceEstimator distanceEstimator) Convenience constructor that picks a moderately permissive set of defaults, each named by aDEFAULT_*constant above.Parameters(DistanceEstimator distanceEstimator, double minRelativeSseGain, double minSeparation, double maxLowMarginRate, double minChildFraction, double maxRelativeImbalance, double lowMarginThreshold, double alphaSseGain, double betaSeparationGain, double gammaImbalancePenalty, double deltaLowMarginPenalty, double minScoreGain) Creates an instance of aParametersrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of thealphaSseGainrecord component.doubleReturns the value of thebetaSeparationGainrecord component.doubleReturns the value of thedeltaLowMarginPenaltyrecord component.Returns the value of thedistanceEstimatorrecord component.final booleanIndicates whether some other object is "equal to" this one.doubleReturns the value of thegammaImbalancePenaltyrecord component.final inthashCode()Returns a hash code value for this object.doubleReturns the value of thelowMarginThresholdrecord component.doubleReturns the value of themaxLowMarginRaterecord component.doubleReturns the value of themaxRelativeImbalancerecord component.doubleReturns the value of theminChildFractionrecord component.doubleReturns the value of theminRelativeSseGainrecord component.doubleReturns the value of theminScoreGainrecord component.doubleReturns the value of theminSeparationrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT_MIN_RELATIVE_SSE_GAIN
public static final double DEFAULT_MIN_RELATIVE_SSE_GAINDefault minimum relative SSE improvement a candidate must show.- See Also:
-
DEFAULT_MIN_SEPARATION
public static final double DEFAULT_MIN_SEPARATIONDefault inter-cluster separation floor.- See Also:
-
DEFAULT_MAX_LOW_MARGIN_RATE
public static final double DEFAULT_MAX_LOW_MARGIN_RATEDefault ceiling on the fraction of vectors sitting near a cluster boundary.- See Also:
-
DEFAULT_MIN_CHILD_FRACTION
public static final double DEFAULT_MIN_CHILD_FRACTIONDefault floor on the smallest cluster's share; seeminChildFraction().- See Also:
-
DEFAULT_MAX_RELATIVE_IMBALANCE
public static final double DEFAULT_MAX_RELATIVE_IMBALANCEDefault ceiling onPartitionEvaluator.PartitionStats.relativeImbalance();1.0disables the check.- See Also:
-
DEFAULT_LOW_MARGIN_THRESHOLD
public static final double DEFAULT_LOW_MARGIN_THRESHOLDSentinel selecting the metric-dependent low-margin threshold.- See Also:
-
DEFAULT_ALPHA_SSE_GAIN
public static final double DEFAULT_ALPHA_SSE_GAINDefault weight of the SSE-gain term in the composite score.- See Also:
-
DEFAULT_BETA_SEPARATION_GAIN
public static final double DEFAULT_BETA_SEPARATION_GAINDefault weight of the separation-gain term in the composite score.- See Also:
-
DEFAULT_GAMMA_IMBALANCE_PENALTY
public static final double DEFAULT_GAMMA_IMBALANCE_PENALTYDefault weight of the imbalance-penalty term in the composite score.- See Also:
-
DEFAULT_DELTA_LOW_MARGIN_PENALTY
public static final double DEFAULT_DELTA_LOW_MARGIN_PENALTYDefault weight of the low-margin-penalty term in the composite score.- See Also:
-
DEFAULT_MIN_SCORE_GAIN
public static final double DEFAULT_MIN_SCORE_GAINDefault minimum composite score improvement required to accept a candidate.- See Also:
-
-
Constructor Details
-
Parameters
Convenience constructor that picks a moderately permissive set of defaults, each named by aDEFAULT_*constant above. Tighten or loosen via the canonical constructor as needed.- Parameters:
distanceEstimator- the distance estimator used for all distance computations
-
Parameters
public Parameters(@Nonnull DistanceEstimator distanceEstimator, double minRelativeSseGain, double minSeparation, double maxLowMarginRate, double minChildFraction, double maxRelativeImbalance, double lowMarginThreshold, double alphaSseGain, double betaSeparationGain, double gammaImbalancePenalty, double deltaLowMarginPenalty, double minScoreGain) Creates an instance of aParametersrecord class.- Parameters:
distanceEstimator- the value for thedistanceEstimatorrecord componentminRelativeSseGain- the value for theminRelativeSseGainrecord componentminSeparation- the value for theminSeparationrecord componentmaxLowMarginRate- the value for themaxLowMarginRaterecord componentminChildFraction- the value for theminChildFractionrecord componentmaxRelativeImbalance- the value for themaxRelativeImbalancerecord componentlowMarginThreshold- the value for thelowMarginThresholdrecord componentalphaSseGain- the value for thealphaSseGainrecord componentbetaSeparationGain- the value for thebetaSeparationGainrecord componentgammaImbalancePenalty- the value for thegammaImbalancePenaltyrecord componentdeltaLowMarginPenalty- the value for thedeltaLowMarginPenaltyrecord componentminScoreGain- the value for theminScoreGainrecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
distanceEstimator
Returns the value of thedistanceEstimatorrecord component.- Returns:
- the value of the
distanceEstimatorrecord component
-
minRelativeSseGain
public double minRelativeSseGain()Returns the value of theminRelativeSseGainrecord component.- Returns:
- the value of the
minRelativeSseGainrecord component
-
minSeparation
public double minSeparation()Returns the value of theminSeparationrecord component.- Returns:
- the value of the
minSeparationrecord component
-
maxLowMarginRate
public double maxLowMarginRate()Returns the value of themaxLowMarginRaterecord component.- Returns:
- the value of the
maxLowMarginRaterecord component
-
minChildFraction
public double minChildFraction()Returns the value of theminChildFractionrecord component.- Returns:
- the value of the
minChildFractionrecord component
-
maxRelativeImbalance
public double maxRelativeImbalance()Returns the value of themaxRelativeImbalancerecord component.- Returns:
- the value of the
maxRelativeImbalancerecord component
-
lowMarginThreshold
public double lowMarginThreshold()Returns the value of thelowMarginThresholdrecord component.- Returns:
- the value of the
lowMarginThresholdrecord component
-
alphaSseGain
public double alphaSseGain()Returns the value of thealphaSseGainrecord component.- Returns:
- the value of the
alphaSseGainrecord component
-
betaSeparationGain
public double betaSeparationGain()Returns the value of thebetaSeparationGainrecord component.- Returns:
- the value of the
betaSeparationGainrecord component
-
gammaImbalancePenalty
public double gammaImbalancePenalty()Returns the value of thegammaImbalancePenaltyrecord component.- Returns:
- the value of the
gammaImbalancePenaltyrecord component
-
deltaLowMarginPenalty
public double deltaLowMarginPenalty()Returns the value of thedeltaLowMarginPenaltyrecord component.- Returns:
- the value of the
deltaLowMarginPenaltyrecord component
-
minScoreGain
public double minScoreGain()Returns the value of theminScoreGainrecord component.- Returns:
- the value of the
minScoreGainrecord component
-