dsc.py 505 B

123456789101112131415161718192021
  1. #!/usr/bin/env python3
  2. # Sorensen-Dice coefficient: $\frac{2|X \cap Y|}{|X| + |Y|}
  3. match_wifi_num_crit = 1
  4. def dsc(known_pt, new_pt):
  5. a = known_pt.wifi_snr
  6. b = new_pt.wifi_snr
  7. up = 0
  8. for mac in a:
  9. if mac in b:
  10. up += 1
  11. if up < match_wifi_num_crit:
  12. return None
  13. return 2 * up / (len(a) + len(b))
  14. if __name__ == '__main__':
  15. from wifiloc import toplev
  16. toplev(infile = "basicdata.csv", sim = dsc, bad_wifi_crit = 5000,
  17. sim_crit = 0.0)