def seperate_via_kmeans(state_space,p,K,tau=0.1):
from scipy.cluster.vq import kmeans
#centres= np.floor(kmeans2(state_space,K)[0]) # these are the original lines
# the following are being added as hacks
#_all_cores_filled_ = False
#while(_all_cores_filled_ == False):
#centres, distributed = kmeans(state_space,K)
#print("going into k means" + "we only have " + str(np.max(distributed)))
#if np.max(distributed) == K-1:
#_all_cores_filled_ = True
# bhack to make just the K means work
centres, stuff = kmeans(state_space,K)
# hack ends here
#proportions = partition_algo_distances(state_space,centres,tau)
proportions = partition_algo_distances_tight(state_space,centres,tau)
sub_state_space, sub_prob = seperate_via_proportions(state_space,proportions, p)
return sub_state_space, sub_prob, centres
评论列表
文章目录