def silhouette_score(X, labels, metric='euclidean', sample_size=None, random_state=None, **kwds):
 if (sample_size is not None):
  (X, labels) = check_X_y(X, labels, accept_sparse=['csc', 'csr'])
  random_state = check_random_state(random_state)
  indices = random_state.permutation(X.shape[0])[:sample_size]
  if (metric == 'precomputed'):
   (X, labels) = (X[indices].T[indices].T, labels[indices])
  else:
   (X, labels) = (X[indices], labels[indices])
 return np.mean(silhouette_samples(X, labels, metric=metric, **kwds))

def silhouette_score ( X , labels , metric = 'euclidean' , sample_size = None , random_state = None , ** kwds ) : if ( sample_size is not None ) : ( X , labels ) = check_X_y ( X , labels , accept_sparse = [ 'csc' , 'csr' ] ) random_state = check_random_state ( random_state ) indices = random_state . permutation ( X . shape [ 0 ] ) [ : sample_size ] if ( metric == 'precomputed' ) : ( X , labels ) = ( X [ indices ] . T [ indices ] . T , labels [ indices ] ) else : ( X , labels ) = ( X [ indices ] , labels [ indices ] ) return np . mean ( silhouette_samples ( X , labels , metric = metric , ** kwds ) )
compute the mean silhouette coefficient of all samples .