kneed is a Python library (current version 0.8.6) for detecting knee (also known as elbow) points in curves. It implements the Kneedle algorithm to identify the point of maximum curvature in a given set of x and y values. The library is actively maintained with regular patch releases and occasional feature updates.
pip install kneedVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `KneeLocator` to find a knee point in a dataset, both by manually specifying `curve` and `direction`, and by automatically detecting them using `find_shape`. The `knee` and `knee_y` attributes provide the x and y coordinates of the detected knee point.
Ensure Matplotlib is installed using `pip install kneed[plot]` if plotting functionality is required.
Explicitly install `scikit-learn` if your application requires it: `pip install scikit-learn`.
Always use valid string values: `curve` can be 'concave' or 'convex'; `direction` can be 'increasing' or 'decreasing'.
Check the `knee` attribute directly; if no knee is found, `kl.knee` will be `None`. Adjust error handling or logging based on this programmatic check instead of relying on warning messages.
Carefully consider the shape and trend of your data. Use `find_shape()` for automatic detection, or plot your data to visually determine the correct parameters. Experiment with different `S` values as well.
Experiment with different `S` values (e.g., 0.1 to 10.0) based on your data's noise level and expected knee sharpness. Consider using `interp_method='polynomial'` and `polynomial_degree` for smoother curves in noisy data.
pip install kneed
from kneed import KneeLocator
pip install kneed[plot]
Ensure 'curve' is 'concave' or 'convex' and 'direction' is 'increasing' or 'decreasing' (e.g., KneeLocator(x, y, curve='concave', direction='increasing')).
Ensure the 'S' parameter is set to a float value of 1.0 or greater, for example, `S=1.0` or `S=3.0`.