otsuka.py 632 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python3
  2. match_wifi_num_crit = 2
  3. # $K = \frac{|A \cap B|}{\sqrt{|A| \times |B|}}$
  4. def otsuka_sim(known_point, new_point):
  5. from math import sqrt
  6. up, d1, d2 = 0.0, 0.0, 0.0
  7. a, b = known_point, new_point
  8. for key in a.wifi_snr:
  9. d1 += 1
  10. if key in b.wifi_snr:
  11. up += 1
  12. for key in b.wifi_snr:
  13. d2 += 1
  14. if up < match_wifi_num_crit:
  15. return None
  16. else:
  17. return up / sqrt(d1) / sqrt(d2)
  18. if __name__ == '__main__':
  19. from wifiloc import toplev
  20. toplev(infile = "basicdata.csv", sim = otsuka_sim, bad_wifi_crit = 5000,
  21. sim_crit = 0.0)