Example #1
0
def pre_analyze(db):
    result = dict()

    mobile.DB = db
    readings = mobile.stream_readings()

    start = time.time()
    H = cluster.Hierarchy(next(readings))
    for i, r in enumerate(readings):
        H.append(r)

    movements = cluster.segment(H, threshold=0.01)
    locs = cluster.locations(movements, threshold=0.5)

    return (H, movements, locs)
Example #2
0
import mobile
import cluster
import itertools
import time
import sys

if sys.argv[1:]:
    mobile.DB = sys.argv[1]
else:
    print("Usage: %s <db>" % sys.argv[0])
    sys.exit()

readings = mobile.stream_readings()

# Clustering
start = time.time()
H = cluster.Hierarchy(next(readings))
for i, r in enumerate(readings):
    H.append(r)
    # if i % 1000 == 0:
    #     print(i)

print("Clustering duration = %.2f seconds" % (time.time() - start))

# Segmentation
start = time.time()
tops = cluster.segment(H, threshold=0.01)
print("Segmentation duration = %.2f seconds" % (time.time() - start))

# Locations
start = time.time()
Example #3
0
import mobile
from cluster import *
from itertools import *

R = list(islice(mobile.stream_readings(), 0, 150))

C1 = Cluster(None, Cluster(None, R[0]), Cluster(None, R[1]))
C2 = Cluster(None, R[-1])

print("Sim = %.4f" % sim(C1, C2))
import mobile
from itertools import *

for r in islice(mobile.stream_readings(), 0, 5):
    print(str(r))