Last active
September 27, 2017 16:15
-
-
Save vlavorini/d35605dad53ec508ade71633a6e8988d 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 __shift(points, sigma, beg, end): | |
dists=dist_batch(points, beg, end) # the distance function just defined | |
weights = gaussian(dists, sigma) | |
expd_w=np.dot(weights.T, points) | |
summed_weight=np.sum(weights,0) | |
return expd_w/np.expand_dims(summed_weight,1) # we return the shifted points | |
def meanshift_batch(points, batches): | |
for i in range(0,n_samples,batches): # we need to loop for each batch, until reach the end | |
last=min(i+batches,n_samples) # we have to select which is the last vector for feeding the following functions | |
points[i:last]=__shift(points, sigma, i, last) # we dinamically update the vectors | |
return points |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment