def fclusterdata(X, t, criterion='inconsistent', metric='euclidean', depth=2, method='single', R=None):
 X = np.asarray(X, order='c', dtype=np.double)
 if ((type(X) != np.ndarray) or (len(X.shape) != 2)):
  raise TypeError('The observation matrix X must be an n by m numpy array.')
 Y = distance.pdist(X, metric=metric)
 Z = linkage(Y, method=method)
 if (R is None):
  R = inconsistent(Z, d=depth)
 else:
  R = np.asarray(R, order='c')
 T = fcluster(Z, criterion=criterion, depth=depth, R=R, t=t)
 return T

def fclusterdata ( X , t , criterion = 'inconsistent' , metric = 'euclidean' , depth = 2 , method = 'single' , R = None ) : X = np . asarray ( X , order = 'c' , dtype = np . double ) if ( ( type ( X ) != np . ndarray ) or ( len ( X . shape ) != 2 ) ) : raise TypeError ( 'The observation matrix X must be an n by m numpy array.' ) Y = distance . pdist ( X , metric = metric ) Z = linkage ( Y , method = method ) if ( R is None ) : R = inconsistent ( Z , d = depth ) else : R = np . asarray ( R , order = 'c' ) T = fcluster ( Z , criterion = criterion , depth = depth , R = R , t = t ) return T
cluster observation data using a given metric .