add laplace to k means

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

add laplace to k means

alaa
Hallo

I have used this k means code on Flink

https://github.com/apache/flink/blob/master/flink-examples/flink-examples-batch/src/main/java/org/apache/flink/examples/java/clustering/KMeans.java

and I would to add noise that follows Laplace distribution to the sum of
data item and to the number to data item when calculate a new cluster center
in each iteration .

for j=1 ---> p do
u' = (sum +Lap(ε))/(num+Laplace(ε))

I have already write Laplace function , but i don't Know how to add it in k
means code and in which line i should write it .

Thank you




--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: add laplace to k means

Yun Gao
Hi alaa, 

    In the KMeans example, in each iteration the new centers is computed in a map-reduce pattern. Each task maintains a part of points and it first choose the new center for each point, and then the new center of the sum(point) and num(point) is computed in the CentroidAccumulator, and the new point is then computed in CentroidAverager by sum(point) / num(point).  Therefore, I think you may change the implementation of  CentroidAverager to add the noise.

Best, 
Yun


------------------------------------------------------------------
From:alaa <[hidden email]>
Send Time:2019 Jul. 23 (Tue.) 21:06
To:user <[hidden email]>
Subject:add laplace to k means

Hallo 

I have used this k means code on Flink 

https://github.com/apache/flink/blob/master/flink-examples/flink-examples-batch/src/main/java/org/apache/flink/examples/java/clustering/KMeans.java

and I would to add noise that follows Laplace distribution to the sum of
data item and to the number to data item when calculate a new cluster center
in each iteration .

for j=1 ---> p do 
u' = (sum +Lap(ε))/(num+Laplace(ε))

I have already write Laplace function , but i don't Know how to add it in k
means code and in which line i should write it .

Thank you




--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/