12345678910111213141516171819202122 |
- #!/usr/bin/env python3
- # $K = \frac{|A \cap B|}{\sqrt{|A| \times |B|}}$
- def otsuka_sim(known_point, new_point):
- from math import sqrt
- up, d1, d2 = 0.0, 0.0, 0.0
- a, b = known_point, new_point
- for key in a.wifi_snr:
- d1 += 1
- if key in b.wifi_snr:
- up += 1
- for key in b.wifi_snr:
- d2 += 1
- if up == 0:
- return None
- else:
- return up / sqrt(d1) / sqrt(d2)
- if __name__ == '__main__':
- from wifiloc import toplev
- toplev(infile = "basicdata.csv", sim = otsuka_sim, bad_wifi_crit = 5000,
- sim_crit = 0.0)
|