示例#1
0
   hac_model = HAC(test[1])

   # Glass dataset
   if "glass" in test[0]:
      kmeans_sfs_glass = np.array([1,3])
      kmeans_model.cluster(data_instances[:,kmeans_sfs_glass])
      print "Kmeans SFS glass performance = %f" % kmeans_model.calculate_performance()

      kmeans_ga_glass = np.array([0,1,2,3,4,5,6])
      kmeans_model = KMeans(test[1])
      kmeans_model.cluster(data_instances[:,kmeans_ga_glass])
      print "Kmeans GA glass performance = %f" % kmeans_model.calculate_performance()

      hac_sfs_glass = np.array([0])
      hac_model.cluster(data_instances[:,hac_sfs_glass])
      print "HAC SFS glass performance = %f" % hac_model.calculate_performance()

   # Iris dataset
   elif "iris" in test[0]:
      kmeans_sfs_iris = np.array([1])
      kmeans_model = KMeans(test[1])
      kmeans_model.cluster(data_instances[:,kmeans_sfs_iris])
      print "Kmeans SFS iris performance = %f" % kmeans_model.calculate_performance()
      kmeans_ga_iris = np.array([0,1])
      kmeans_model = KMeans(test[1])
      kmeans_model.cluster(data_instances[:,kmeans_ga_iris])
      print "Kmeans GA iris performance = %f" % kmeans_model.calculate_performance()
      hac_sfs_iris = np.array([0])
      hac_model.cluster(data_instances[:,hac_sfs_iris])
      print "HAC SFS glass performance = %f" % hac_model.calculate_performance()
      hac_ga_iris = np.array([1,2])
示例#2
0
    if "glass" in test[0]:
        kmeans_sfs_glass = np.array([1, 3])
        kmeans_model.cluster(data_instances[:, kmeans_sfs_glass])
        print("K-means SFS glass performance = %f" %
              kmeans_model.calculate_performance())

        kmeans_ga_glass = np.array([0, 1, 2, 3, 4, 5, 6])
        kmeans_model = KMeans(test[1])
        kmeans_model.cluster(data_instances[:, kmeans_ga_glass])
        print("K-means GA glass performance = %f" %
              kmeans_model.calculate_performance())

        hac_sfs_glass = np.array([0])
        hac_model.cluster(data_instances[:, hac_sfs_glass])
        print("HAC SFS glass performance = %f" %
              hac_model.calculate_performance())

    # Iris dataset
    elif "iris" in test[0]:
        kmeans_sfs_iris = np.array([1])
        kmeans_model = KMeans(test[1])
        kmeans_model.cluster(data_instances[:, kmeans_sfs_iris])
        print("K-means SFS iris performance = %f" %
              kmeans_model.calculate_performance())

        kmeans_ga_iris = np.array([0, 1])
        kmeans_model = KMeans(test[1])
        kmeans_model.cluster(data_instances[:, kmeans_ga_iris])
        print("K-means GA iris performance = %f" %
              kmeans_model.calculate_performance())