如何在内核密度估计中找到局部最大值? [英] How to find Local maxima in Kernel Density Estimation?

查看:67
本文介绍了如何在内核密度估计中找到局部最大值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用内核密度估计器(KDE)进行过滤(以消除异常值和噪声).我在3D(d = 3)数据点中应用了KDE,这给了我概率密度函数(PDF)f(x).现在我们知道密度估计的局部最大值f(x)定义了数据点簇的中心.因此,我的想法是定义适当的f(x)来确定这些簇.

I'm trying to make a filter (to remove outlier and noise) using kernel density estimators(KDE). I applied KDE in my 3D (d=3) data points and that gives me the probability density function (PDF) f(x). Now as we know local maxima of density estimation f(x) defined the centers of the clusters of data points. So my idea is to define the appropriate f(x) which will determine those clusters.

我的问题是,哪种方法以及哪种方法更适合于在f(x)中找到局部最大值的目的.如果有人可以提供一些示例代码/想法,我将不胜感激.

My question is how and what method will be better suited for this purpose of finding local maxima in f(x). If anyone can provide me some example code/ idea I will really appreciate it.

这是找到在3D数据中给出f(x)的KDE的代码.

Here is the code to find the KDE which give f(x) in 3D data.

import numpy as np
from scipy import stats

data = np.array([[1, 4, 3], [2, .6, 1.2], [2, 1, 1.2],
         [2, 0.5, 1.4], [5, .5, 0], [0, 0, 0],
         [1, 4, 3], [5, .5, 0], [2, .5, 1.2]])
data = data.T 
kde = stats.gaussian_kde(data)
minima = data.T.min(axis=0)
maxima = data.T.max(axis=0)
space = [np.linspace(mini,maxi,20) for mini, maxi in zip(minima,maxima)]
grid = np.meshgrid(*space)
coords = np.vstack(map(np.ravel, grid))
#Evaluate the KD estimated pdf at each coordinate
density = kde(coords)

推荐答案

您将要使用称为的算法均值移位.它是一种聚类算法,可以通过找到KDE的模式(f(x)的最大值)来工作.请注意,为您的KDE设置的带宽将影响模式的数量及其位置.由于您使用的是python,因此 scikit-learn .

You will want to use an algorithm called Mean Shift. Its a clustering algorithm that works by finding the modes (aka maxima of f(x)) of the KDE. Note that the bandwidth set for your KDE will impact the number of modes and their locations. Since you are using python, there is an implementation in scikit-learn.

这篇关于如何在内核密度估计中找到局部最大值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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