Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
y1 = np.random.randint(5,10,5)
y2 = np.random.randint(15,20,5)
y3 = np.random.randint(5,10,5)
y = np.append(y1 , y2)
y = np.append(y , y3)
y_cum = y.cumsum()
df_test = pd.DataFrame({'x': range(len(y)), 'y_cum': y_cum, 'y': y})
if we plot these data we can see an "elbow" (at 4 in the x-axis) and a "knee" (at 9 in the x-axis)
import matplotlib.pyplot as plt
plt.plot(df_test['x'], df_test['y_cum'])
I am using from kneed import KneeLocator
to detect them.
I use the following code to detect the elbow:
kneedle = KneeLocator(df_test['x'], df_test['y'], curve='convex', direction='increasing', online=False, S=1)
elbow_point = kneedle.elbow
elbow_point
and the following code to detect the knee:
kneedle = KneeLocator(df_test['x'], df_test['y'], curve='concave', direction='increasing', online=False, S=1)
elbow_point = kneedle.elbow
elbow_point
The first one gives as output 13
and the second gives as output 1
, which are not the correct values
I am a bit lost why these values pop up. I have looked into the source code but I couldnt figure it out.
Any ideas ?
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.