otsuka.py 590 B

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