该代码是K-means算法中的Map类,用于将元素进行中心点归属判别并输出中心点序号作为key。在setup()方法中,读取中心点文件并将其存储在centers变量中。在map()方法中,将输入的元素转换成ArrayList类型,并调用CalUtil中的selectNearestCenter()方法选择最近的中心点,将其作为key,将原始元素作为value输出。最终,输出的结果会被传递给Reducer类进行新中心点的计算。

package comhuiluczPcluster;import comhuiluczPutilCalUtil;import comhuiluczPutilDataUtil;import orgapachehadoopconfConfiguration;import orgapachehadoopioText;import orgapachehadoopmapreduceMapper;impor

原文地址: https://www.cveoy.top/t/topic/hdNJ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录