I am trying to create a filter (to remove outlier and noise) using kernel density estimates (KDE). I applied KDE at my 3D data points (d = 3) and this gives me the probability density function (PDF) f (x). Now that we know that the local maxima of the density estimate f (x) determine the centers of the clusters of data points. So my idea is to determine the appropriate f (x) that defines these clusters.
My question is how and which method is best suited for this purpose to find local maxima in f (x). If anyone can provide me with a code / idea example, I will be very grateful.
Here is the KDE search code that gives 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))
density = kde(coords)