相关文章推荐
低调的饭盒  ·  javascript - ...·  11 月前    · 
寂寞的山楂  ·  javascript - Uncaught ...·  1 年前    · 
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 ?

In my limited experience, kneed cannot handle noise well. But then again, which signal detection algorithms can? – Mr. T Dec 17, 2020 at 12:33 If you change online=True, it finds the knee at 9. But, overall, this seems like a bug attributed to the normalization/transformation step in the algorithm. If you create an issue on GitHub, I will take a look when I get a chance. There is a new, interactive dashboard, where you can paste your data and tune the parameters on the fly. You might find it helpful for selecting the appropriate values for the parameters. – Kevin Dec 17, 2020 at 14:43

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.