Knee Detection¶
knee_detection
¶
Knee point detection for Pareto fronts.
Implements multiple methods for identifying "knee" points - solutions that represent the best compromise between competing objectives.
Functions¶
detect_knee_points
¶
detect_knee_points(objectives: ndarray | DataFrame, method: str = 'angle', n_knees: int = 1, normalize: bool = True) -> ndarray
Detect knee points on Pareto front.
A knee point represents the best compromise - maximum trade-off benefit per unit sacrifice. These are often the most preferred solutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objectives
|
ndarray | DataFrame
|
Array or DataFrame of objective values (assumed minimization) |
required |
method
|
str
|
Detection method ('angle', 'distance', 'tradeoff', 'curvature') |
'angle'
|
n_knees
|
int
|
Number of knee points to detect |
1
|
normalize
|
bool
|
Whether to normalize objectives to [0,1] |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of indices of knee points, sorted by knee quality (best first) |
Source code in optiscope/analysis/knee_detection.py
find_knee_region
¶
find_knee_region(objectives: ndarray | DataFrame, width: float = 0.1, method: str = 'angle', normalize: bool = True) -> tuple[ndarray, float, float]
Find knee region instead of single point.
Returns a region around the knee point where solutions are similar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objectives
|
ndarray | DataFrame
|
Objective values |
required |
width
|
float
|
Width of knee region (as fraction of normalized space) |
0.1
|
method
|
str
|
Knee detection method |
'angle'
|
normalize
|
bool
|
Normalize objectives |
True
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, float, float]
|
Tuple of (indices in knee region, region_start, region_end) |
Source code in optiscope/analysis/knee_detection.py
rank_by_knee_distance
¶
rank_by_knee_distance(objectives: ndarray | DataFrame, knee_indices: ndarray, normalize: bool = True) -> ndarray
Rank all solutions by distance to nearest knee point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objectives
|
ndarray | DataFrame
|
Objective values |
required |
knee_indices
|
ndarray
|
Indices of knee points |
required |
normalize
|
bool
|
Normalize objectives |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of ranks (0 = on knee, higher = farther from knee) |
Source code in optiscope/analysis/knee_detection.py
calculate_knee_quality_metrics
¶
calculate_knee_quality_metrics(objectives: ndarray | DataFrame, knee_indices: ndarray, normalize: bool = True) -> dict
Calculate quality metrics for detected knee points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objectives
|
ndarray | DataFrame
|
Objective values |
required |
knee_indices
|
ndarray
|
Detected knee point indices |
required |
normalize
|
bool
|
Normalize objectives |
True
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with quality metrics |