best_u = np.loadtxt(filename_template.format(tag='u'), delimiter=",") best_u_ew = np.loadtxt(filename_template_ew.format(tag='u'), delimiter=",") cluster_ew = np.argmax(best_u_ew, axis=1) cluster = np.argmax(best_u, axis=1) N, ND = data.shape knn = 8 #create neighbourdhood EW print("building neighbourhood, location.shape=", locations.shape) kdtree = cKDTree(locations_ore) neighbourhood, distances = make_neighbourhood(kdtree, locations_ore, knn, max_distance=np.inf) distances = np.array(distances) #spatial EW verbose_level = 2 clusters_graph_ew = graph_cut(locations_ore, neighbourhood, best_u_ew, unary_constant=100.0, smooth_constant=80.0, verbose=1) for i in range(N): print(i, cluster_ew[i],
target = False force = False file_template = '../results/bm_{set}_swfc_%d.csv'%NC best_centroids = np.loadtxt(file_template.format(set='centroids'),delimiter=",") best_weights = np.loadtxt(file_template.format(set='weights'),delimiter=",") best_u = np.loadtxt(file_template.format(set='u'),delimiter=",") clusters = np.argmax(best_u,axis=1) N,ND = data.shape knn = 15 #create neighbourdhood print("building neighbourhood, location.shape=",locations.shape) kdtree = cKDTree(locations) neighbourhood,distances = make_neighbourhood(kdtree,locations,knn,max_distance=2.0) distances = np.array(distances) #spatial verbose_level = 2 clusters_graph = np.int32(graph_cut(locations,neighbourhood,best_u,unary_constant=70.0,smooth_constant=15.0,verbose=1)) #for i in range(N): # print(i,clusters[i],best_u[i],clusters_graph[i],sep=',') np.savetxt("../results/final_bm_clusters_swfc_%d.csv"%NC,clusters_graph,delimiter=",",fmt="%d")
#filter just 0-50 #indices = np.where(locations[:,0] <= 50)[0] #indices = np.where(locations[indices,1] <= 50)[0] #locations = locations[indices,:] #X = X[indices,:] N, ND = X.shape NC = 4 knn = 8 #create neighbourdhood print("building neighbourhood") kdtree = cKDTree(locations) neighbourhood, distances = make_neighbourhood(kdtree, locations, knn) distances = np.array(distances) #create U fake #best_u = np.zeros((N,NC)) # #for i in range(N): # best_u[i,int(X[i,6])] = 1.0 #spatial verbose_level = 2 clusters_graph = graph_cut(locations, neighbourhood, best_u, unary_constant=100.0, smooth_constant=100.0,