Created
November 18, 2011 14:14
-
-
Save conradlee/1376552 to your computer and use it in GitHub Desktop.
Mean shift kernel update functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.metrics.pairwise import euclidean_distances | |
def gaussian_kernel_update(x, points, bandwidth): | |
distances = euclidean_distances(points, x) | |
weights = np.exp(-1 * (distances ** 2 / bandwidth ** 2)) | |
return np.sum(points * weights, axis=0) / np.sum(weights) | |
def flat_kernel_update(x, points, bandwidth): | |
return np.mean(points, axis=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment