Ejemplo n.º 1
0
def get_seqs_by_weekdays(fp):
    result = []
    dt_locs = get_wifi_seqs(fp, 60*10, 20)
    days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
    for day in days:
        #print day
        #pprint(locs)
        seqs = []
        seq_freq = {}
        avg_seq_len = 0
    
        for dt, entries in dt_locs:
            dt_obj = datetime.strptime(dt, "%d%b%Y")
            weekday = dt_obj.strftime("%A")
            #if weekday != 'Sunday' and weekday != 'Saturday':
            if weekday == day:
         
                seqs.append(entries)

        #pprint(seqs)
        result.append((day, seqs))
        
    
    for pair in result:
        print pair[0]
        for entry in pair[1]:
            print entry
 
    return result
Ejemplo n.º 2
0
def get_feature():
    id_feature = {}
    addr_dir = r'C:\Users\Sophie\workspace\Personality\old_code\data\by_subjects'
    for file in os.listdir(addr_dir):
        if not file.endswith('.csv'):
            continue
        
        id = file.split('.')[0][-2:]
        if int(id) >= 45:
            continue     
#         if id in WIFI_OFF_CAMPUS:
#             continue
        fp = os.path.join(addr_dir, file)
        print '----------'
        print 'id: ' + id
        
        #seqs = get_wifi_seqs(fp, 60*10, 20)
        seqs = get_wifi_seqs(fp, 60*5, 30)
        #print seqs
        #print len(seqs)
        result = get_avg_edit_dist(seqs)
        print result
        
        id_feature[id] = result
        
    return id_feature
Ejemplo n.º 3
0
def get_feature():
    id_feature = {}
    addr_dir = os.path.join(CUR_DIR, 'data', 'by_subjects')
    for file in os.listdir(addr_dir):
        if not file.endswith('.csv'):
            continue
        
        id = file.split('.')[0][-2:]
        if int(id) >= 45:
            continue     
        if id in WIFI_OFF_CAMPUS:
            continue
        fp = os.path.join(addr_dir, file)
        print '----------'
        print 'id: ' + id
        
        seqs = get_wifi_seqs(fp, 60*10, 30)
        #result = avg_seq_len(seqs)
        result = num_pattern(seqs)
        print result
        
        id_feature[id] = result
        
    return id_feature
Ejemplo n.º 4
0
    ids = []
    input_dir = os.path.join(CUR_DIR, 'data', 'by_subjects')
    for file in os.listdir(input_dir):
        if not file.endswith('.csv'):
            continue    
        id = file.split('.')[0][-2:]
        if int(id) >= 45:
            continue     
        if id in WIFI_OFF_CAMPUS:
            continue
        fp = os.path.join(input_dir, file)
        
        ids.append(id)
        print id
        
        seqs = get_wifi_seqs(fp, DURATION_CUT, NUM_DAYS)
#         for seq in seqs:
#             print seq
            
        replace_home(seqs, id)
        seqs_by_subject.append(seqs)
        all_seqs.extend(seqs)
    


    freq_pat = []
    gsp(all_seqs, 1, [], freq_pat)
    #pprint(freq_pat)
    print len(freq_pat)
    for i, p in enumerate(freq_pat):
        print i, p