def csoms(X, D, params=()):
pnames = ['neighbour', 'learning_rate', 'input_length_ratio']
dflts = [ 0.1, 0.2, -1]
if isinstance(params, np.ndarray):
paramsloc = params.tolist()
else:
paramsloc = params
(neighbour, learning_rate, input_length_ratio) = ds.resolveargumentpairs(pnames, dflts, paramsloc)
Xloc = np.array(X)
K = D[0] * D[1] # Number of clusters
N = Xloc.shape[0] # Number of genes
Ndim = Xloc.shape[1] # Number of dimensions in X
som = sompy.SOM(D, Xloc)
som.set_parameter(neighbor=neighbour, learning_rate=learning_rate, input_length_ratio=input_length_ratio)
centres = som.train(N).reshape(K, Ndim)
dists = [[spdist.euclidean(c, x) for c in centres] for x in Xloc]
C = [np.argmin(d) for d in dists]
return clustVec2partMat(C, K)
评论列表
文章目录