anonymizer.py 810 B

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. """
  3. run top_down_greedy_anonymization with given argv
  4. """
  5. import copy
  6. import sys
  7. import os
  8. from top_down_greedy.top_down_greedy_anonymization import \
  9. Top_Down_Greedy_Anonymization
  10. sys.path.insert(1, os.path.join(sys.path[0], '..'))
  11. from utils.data import reorder_columns, restore_column_order
  12. DATA_SELECT = 'a'
  13. def tdg_get_result_one(att_trees, data, k, path, qi_index, SA_index):
  14. "run Top_Down_Greedy_Anonymization for one time, with k=10"
  15. print("K=%d" % k)
  16. result, eval_result = Top_Down_Greedy_Anonymization(att_trees, reorder_columns(
  17. copy.deepcopy(data), qi_index), k, len(qi_index), SA_index)
  18. print("NCP %0.2f" % eval_result[0] + "%")
  19. print("Running time %0.2f" % eval_result[1] + "seconds")
  20. return restore_column_order(result, qi_index)