util.py 555 B

123456789101112131415161718192021222324
  1. import pandas as pd
  2. class Constants:
  3. CLUSTER_NUM = 100
  4. ROUND_LENGTH = 3600 # in seconds
  5. CLUSTER_SIZE = 30 # minimum cluster size that must be satisfied by forwarding messages
  6. NUM_COVER = 1
  7. MAX_DELAY = 3
  8. ENCODING = 'UTF-8'
  9. def cnt_cluster(model):
  10. """Count number of users in each cluster"""
  11. cnt = pd.Series(model.labels_).value_counts().to_frame()
  12. cnt.columns = ['count']
  13. print('Non_empty cluster number:', len(cnt))
  14. print('The number of users in each cluster is:\n', cnt)
  15. return cnt