You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by alaa <al...@hotmail.com> on 2019/07/23 13:06:10 UTC

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/

Re: add laplace to k means

Posted by Yun Gao <yu...@aliyun.com>.
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 <al...@hotmail.com>
Send Time:2019 Jul. 23 (Tue.) 21:06
To:user <us...@flink.apache.org>
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/