コード例 #1
0
def clusterC(CONFIG,case_in='',case_out=''):
	if CONFIG.CL_TYPE =='EXT': print ("CLUSTERS_DATA_EXTERNAL is defined, please check what you realy want to do!"); exit()

	exec('from clustering.'+CONFIG.CLUSTERING_METHOD+' import clustering')
	os.system('mkdir -p cl_data')
	clusters,labels= clustering(READ(CONFIG.RED_DATA+case_in,CONFIG.MASK),CONFIG.dict_clust)
	np.savetxt(CONFIG.CL_DATA+case_out,clusters)
	np.savetxt(CONFIG.LAB_DATA+case_out,labels)

	if CONFIG.RED_TYPE =='EXT': RED_PROP='### REDUCTION USED ###\nfrom external data = '+REDUCED_DATA_EXTERNAL
	else			  : RED_PROP=open(CONFIG.REDUCTION_INFO+case_in,'r').read()

	prt(CONFIG.CLUSTER_INFO+case_out,RED_PROP,'w')
	print_info(CONFIG.CLUSTERING_METHOD,CONFIG.dict_clust,'### CLUSTERING USED ###',CONFIG.RED_DATA,CONFIG.CLUSTER_INFO+case_out,'a')
	prt(CONFIG.CLUSTER_INFO+case_out,'\n\t-outputs:','a')
	prt(CONFIG.CLUSTER_INFO+case_out,'n_clusters = '+str(clusters.shape[0]),'a')
	PRT_FMSG('CLUSTER CENTERS printed to','CLUSTERS CENTERS not printed',CONFIG.CL_DATA+case_out)
	PRT_FMSG('CLUSTER LABELS printed to','CLUSTERS LABELS not printed',CONFIG.LAB_DATA+case_out)
	return clusters,labels