Mannaggia
Mannaggia

Reputation: 4829

How to smooth / filter a function in a n-dimensional space using python?

I have function defined in an n-dimensional space which I represent with (X,Y), where X is an array of size mxn containing the input features and Y an array of size mx1 containing the output. So there are m points in an d-dimensional space with m >> n.

I would like to smooth the values of Y (output). In the case of 1 or 2 dimensions I would probably use smoothed splines. In the case of n dimensions I do not really know... I thought about the median filter in scipy (median_filter), but it is not clear to me how to find neighbours in X and fetch the corresponding values in Y to compute the median.

Any ideas? Thanks!

Upvotes: 1

Views: 714

Answers (1)

HYRY
HYRY

Reputation: 97331

You can use scipy.spatial.KDTree to find points in some radius and then find the median value of Y.

Or maybe use some regression method in sklearn, such as Support Vector Regression

Upvotes: 1

Related Questions