@@ -0,0 +1,1508 @@
+package kmeans;%0A%0Aimport java.io.IOException;%0A%0Aimport org.apache.hadoop.io.IntWritable;%0Aimport org.apache.hadoop.mapreduce.Reducer;%0A%0Aimport datapoint.DataPoint;%0A%0A/**%0A  * Reducer class for the k-Means Clustering.%0A  */%0Apublic class KMeansReducer extends Reducer%3CDataPoint, DataPoint, IntWritable, DataPoint%3E%0A%7B%0A%09/**%0A%09 * Output key for the k-Means Centroid%0A%09 */%0A%09public static int CENTROID_KEY = 1;%0A%09/**%0A%09  * Overridden reduce method of the Reduce class%0A%09  * @param key%0A%09  * - A k-Means Cluster Centroid%0A%09  * @param value%0A%09  * - A list of Data Points associated to this Cluster Centroid%0A%09  *%09@param context%0A%09  * %3Cb%3EOutputs:%3C/b%3E%3Cbr%3E %0A%09  *%09(key, value) pairs where %3Cbr%3E%0A%09  *%09key is a k-Means Cluster Centroid %3Cbr%3E%0A%09  *%09value is one of the Data Points in the Iterable list %3Cbr%3E%3Cbr%3E%0A%09  * %0A%09  * The function receives a (key, value) pair, where %0A%09  * the key is a k-Means Cluster Centroid,%0A%09  * the value is a Iterable list of Data Points in this Cluster.%0A%09  * It calculates the average of all the Data Points as the new Cluster Centroid.%0A%09  * It outputs the pair (1, New Cluster Centroid, that is Average of all Data Points).%0A%09  */%0A%09@Override%0A%09public void reduce(DataPoint key, Iterable%3CDataPoint%3E values, Context context)%0A%09%09throws IOException, InterruptedException%0A%09%7B%0A%09%09// Find average Data Point and output it%0A%09%09DataPoint dataPoint = DataPoint.getAverageDataPoint(values);%0A%09%09context.write(new IntWritable(KMeansReducer.CENTROID_KEY), dataPoint);%0A%0A%09%09// Increment the centroid key%0A%09%09KMeansReducer.CENTROID_KEY++;%0A%09%7D%0A%7D%0A

Create KMeansReducer.java