How to find local maxima in the estimation of core density?

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))
#Evaluate the KD estimated pdf at each coordinate
density = kde(coords)
+4
source share
2

. , (aka maxima f (x)) KDE. , , KDE, . python, scikit-learn.

+3

, , . . no_samples , .

from scipy.stats import gaussian_kde
import numpy as np

    def estimate_maxima(data):

      kde = gaussian_kde(data)

      no_samples = 10

      samples = np.linspace(0, 10, no_samples)

      probs = kde.evaluate(samples)

      maxima_index = probs.argmax()

      maxima = samples[maxima_index]

      return maxima
0

All Articles