以稳定的方式找到曲线的弯头? [英] Finding the elbow point of a curve in a stable way?

查看:122
本文介绍了以稳定的方式找到曲线的弯头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道关于这个主题.但是,这次我想最后确定Python的实际实现.

I am aware of the existence of this, and this on this topic. However, I would like to finalize on an actual implementation in Python this time.

我唯一的问题是肘点似乎从我的代码的不同实例中改变.观察这篇文章中显示的两个图.尽管它们在视觉上看起来相似,但肘点的值发生了显着变化.两条曲线均来自平均20次不同的运行.即使那样,肘点的值也有明显的变化.我可以采取哪些预防措施来确保该值落在某个范围内?

My only problem is that the elbow point seems to be changing from different instantiations of my code. Observe the two plots shown in this post. While they appear to be visually similar, the value of the elbow point changed significantly. Both the curves were generated from an average of 20 different runs. Even then, there is a significant shift in the value of the elbow point. What precautions can I take to make sure that the value falls within a certain bound?

我的尝试如下所示:

def elbowPoint(points):
  secondDerivative = collections.defaultdict(lambda:0)
  for i in range(1, len(points) - 1):
    secondDerivative[i] = points[i+1] + points[i-1] - 2*points[i]

  max_index = secondDerivative.values().index(max(secondDerivative.values()))
  elbow_point = max_index + 1
  return elbow_point

points = [0.80881476685027154, 0.79457906121371058, 0.78071124401504677, 0.77110686192601441, 0.76062373158581287, 0.75174963969985187, 0.74356408965979193, 0.73577573557299236, 0.72782434749305047, 0.71952590556748364, 0.71417942487824781, 0.7076502559300516, 0.70089375208028415, 0.69393584640497064, 0.68550490458450741, 0.68494440529025913, 0.67920157634796108, 0.67280267176628761]
max_point = elbowPoint(points)  

推荐答案

听起来您真正关心的是如何平滑包含噪声的数据?在这种情况下,您应该先对数据拟合曲线,然后找到拟合曲线的弯头?

Its sounds like your actual concern is how to smooth your data as it contains noise? in which case perhaps you should fit a curve to the data first, then find the elbow of the fitted curve?

这是否可行取决于噪声源,以及噪声对您的应用是否重要?顺便说一句,当您从拟合中忽略点时(可能具有足够高的多项式,您总是会得到一个很好的拟合),您可能希望通过查看数据的变化(或希望没有变化)来查看拟合对数据的敏感程度特定的数据集,但您可能对一般情况感兴趣)

Whether this will work would depend on the source of the noise, and if the noise is important for your application? by the way you may want to see how sensitive your fit is to your data by seeing how it changes (or hopefully doesn't) when a point is omitted from the fit (obviously with a high enough polynomial you will always get a good fit to a specific set of data, but you are presumably interested in the general case)

直觉上我不知道这种方法是否可以接受,尽管我认为对小错误的敏感性很差.最终通过拟合曲线,您说的是,在理想情况下,基础过程是由曲线建模的,与曲线的任何偏差都是误差/噪声

I have no idea if this approach is acceptable, intuitively though i'd think that sensitivity to small errors is bad. ultimately by fitting a curve you are saying that the underlying process is, in the ideal case, modelled by the curve, and any deviation from the curve is an error/noise

这篇关于以稳定的方式找到曲线的弯头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆