Last active
December 19, 2018 15:50
-
-
Save vlavorini/1f2bd4ac469a2f7d2b5d186fe2dd4112 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def meanshift(data, sigma, steps): | |
d1 = np.copy(data) # Need to copy the data, don't want to modify the originals | |
for it in range(steps): # at each step | |
for i, p in enumerate(d1): # for each point | |
dists = dist_poinc( p, d1) # we calculate the distance from that point to all the other ones | |
weights = gaussian(dists, sigma) # then we weight those distances by our gaussian kernel | |
d1[i] = (np.expand_dims(weights,1)*d1).sum(0) / weight.sum() # and substitute the point with the weighted sum | |
return d1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
on line 7, should be weights.sum( )