index_label.append(label.index(i)) # print(index_label) print(len(index_label),len(set(TAG_label))) """用多标记学习进行预测""" k =[];k1=[] k2=[];k3=[] labelcount =1853 endianness = 'little' feature_type = 'float' encode_nominal = True load_sparse = True X, y1 = Dataset.load_arff_to_numpy("medical_data2.arff", labelcount=labelcount, endian="little", input_feature_type=feature_type, encode_nominal=encode_nominal, load_sparse=load_sparse) X=X.toarray() #kmeans=KMeans(n_clusters=13,random_state=0).fit(X) kmeans2=hcluster.fclusterdata(X, criterion='maxclust', t=12) #kmeans = SpectralClustering(n_clusters=8).fit(X) #print kmeans.labels_ index_0=[];index_1=[];index_2=[];index_3=[];index_4=[];index_5=[] for i,li in enumerate(kmeans2): if li==0: index_0.append(i) elif li==1: index_1.append(i) elif li==2:
# where the labels are located, # big = at the beginning of the file endianness = 'little' # dtype used in the feature space feature_type = 'float' # whether the nominal attributes should be encoded as integers encode_nominal = True # if True - use the sparse loading mechanism from liac-arff # if False - load dense representation and convert to sparse load_sparse = True # load data X_train, y_train = Dataset.load_arff_to_numpy( "path_to_data/dataset-train.dump.bz2", labelcount=labelcount, endian="big", input_feature_type=feature_type, encode_nominal=encode_nominal, load_sparse=load_sparse) X_test, y_test = Dataset.load_arff_to_numpy( "path_to_data/dataset-train.dump.bz2", labelcount=labelcount, endian="big", input_feature_type=feature_type, encode_nominal=encode_nominal, load_sparse=load_sparse)