package com.huiluczP;

import com.huiluczP.center.CenterRandomAdapter; import com.huiluczP.cluster.KmeansAdapter; import com.huiluczP.util.DataUtil; import org.apache.hadoop.conf.Configuration; import java.io.IOException;

public class KmeansRun { public static void main(String[] args){ String dataName = args[0]; int k = Integer.parseInt(args[1]);

    String centerPath = DataUtil.HDFS_OUTPUT + '/centers.txt';
    String newCenterPath = DataUtil.HDFS_OUTPUT + '/new_centers.txt';
    String dataPath = DataUtil.HDFS_INPUT + '/' + dataName;
    String clusterResultPath = DataUtil.HDFS_OUTPUT + '/kmeans_cluster_result.txt';

    CenterRandomAdapter.createRandomCenter(dataPath, centerPath, k);

    for(int i=0;i<30;i++){
        KmeansAdapter.start(dataPath, centerPath, newCenterPath);
        if(KmeansAdapter.checkStop(centerPath, newCenterPath)) {
            break;
        }
    }
    KmeansAdapter.createClusterResult(dataPath, centerPath, clusterResultPath);
}

}

KmeansRun: A Java Implementation of K-Means Clustering Algorithm

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

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