Detecting knee- / elbow points in a graph

Photo by Lucaxx Freire on Unsplash [1]

Theory

N = 10,000 random standard normal distributed data points displayed in a histogram (Image by author)
Sorted data displayed as CDF with maximum curvature indicated (Image by author, inspired by Figure 1 in Satopää et al., 2011 [2])
import kneed
kneed.DataGenerator.figure2()
Original data as line chart (Image by author)
Smoothing spline for original data points (Image by author)
Normalized data (Image by author)
Perpendicular lines indicating perpendicular distances (Image by author, inspired by Figure 2a in Satopää et al., 2011 [2])
Perpendicular lines rotated by 45 degrees representing difference values (Image by author, inspired by Figure 2b in Satopää et al., 2011 [2])
Maximum curvature at local maximum of difference curve (Image by author, inspired by Figure 2c in Satopää et al., 2011 [2])
Threshold indicated at y = 0.43 (Image by author, inspired by Figure 2c in Satopää et al., 2011 [2])

kneed

Figure 2 from Satopää et al., 2011 [2] with “kneed” (Image by author)
# calculate and show knee/elbow
kneedle = kneed.KneeLocator(…)
knee_point = kneedle.knee #elbow_point = kneedle.elbow
print(‘Knee: ‘, knee_point) #print(‘Elbow: ‘, elbow_point)
kneedle.plot_knee()

Applications

Clustering

Elbow Method (Image by author)
Elbow detection with Elbow Method with “kneed” (Image by author)
k-distances graph (Image by author)
Knee detection in k-distances graph with “kneed” (Image by author)

Classification

Receiver-Operating curve (Image by author)
Knee detection for Receiver-Operating Operating curve with “kneed” (Image by author)

Final remarks

References

Industrial and organizational psychologist specialized in the fields of Data Analytics and Data Science with a focus on Machine Learning

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store