Beispiel #1
0
def generate_route_clusters(user, nClusters = -1):
    ## update route clusters:
    print "In profile, generating route clusters for %s" % user
    routes_user = user_route_data(user,get_section_db())
    #print(routes_user.keys())
    update_user_routeDistanceMatrix(user,routes_user,step1=100000,step2=100000,method='dtw')
    if nClusters == -1:
        nClusters = int(math.ceil(len(routes_user)/8) + 1)
    clusters_user = kmedoids(routes_user,nClusters,user,method='dtw')
    update_user_routeClusters(user,clusters_user[2],method='dtw')
Beispiel #2
0
def generate_route_clusters(user):
    print "In profile, generating route clusters for %s" % user
    data = cp.read_data(uuid=user)
    data, bins = cp.remove_noise(data, 300)
    num_clusters, labels, data = cp.cluster(data, len(bins))
    clusters = {}
    for i in range(num_clusters):
        idx = labels.index(i)
        tripid = data[idx].trip_id
        clusters[tripid] = []
        for j in range(len(labels)):
            if labels[j] == i:
                clusters[tripid].append(data[j].trip_id)
    update_user_routeClusters(user, clusters)
Beispiel #3
0
def generate_route_clusters(user):
    print "In profile, generating route clusters for %s" % user
    data = cp.read_data(uuid=user)
    data, bins = cp.remove_noise(data, 300)
    num_clusters, labels, data = cp.cluster(data, len(bins))
    clusters = {}
    for i in range(num_clusters):
        idx = labels.index(i)
        tripid = data[idx].trip_id
        clusters[tripid] = []
        for j in range(len(labels)):
            if labels[j] == i:
                clusters[tripid].append(data[j].trip_id)
    update_user_routeClusters(user, clusters)