无法处理字符串属性!聚集eroor

时间:2017-09-21 06:33:23

标签: weka

请帮忙! 这是我的代码:

    SimpleKMeans kmeans = new SimpleKMeans();

    kmeans.setSeed(10);

    //important parameter to set: preserver order, number of cluster.
    kmeans.setPreserveInstancesOrder(true);
    kmeans.setNumClusters(5);


    BufferedReader datafile = readDataFile("newfile.arff"); 
    Instances data = new Instances(datafile);

    System.out.println("weather");
    kmeans.buildClusterer(data);

    // This array returns the cluster number (starting with 0) for each instance
    // The array has as many elements as the number of instances
    int[] assignments = kmeans.getAssignments();

    int i=0;
    for(int clusterNum : assignments) {
        System.out.printf("Instance %d -> Cluster %d \n", i, clusterNum);
        i++;

这是我的例外:

  

线程中的异常" main"   weka.core.UnsupportedAttributeTypeException:   weka.clusterers.SimpleKMeans:无法处理字符串属性!

1 个答案:

答案 0 :(得分:0)

如果缺少任何值,它不会对数据进行聚类。因此错误。如果在文件或db中添加值,则它会处理数据并执行群集。