def printBasicNoteStats(user): notes = Note.objects.filter(owner=user) print "# Notes:", notes.count() noteLen = map(lambda x:len(x.contents), notes) noteLines = map(lambda x:len(x.contents.split('\n')), notes) print "Ave #Chars:", mean(noteLen), ", Ave Var:", variance(noteLen) print "Ave #Lines:", mean(noteLines), ", Ave Var:", variance(noteLines)
def printBasicNoteStats(user): notes = Note.objects.filter(owner=user) print "# Notes:", notes.count() noteLen = map(lambda x: len(x.contents), notes) noteLines = map(lambda x: len(x.contents.split('\n')), notes) print "Ave #Chars:", mean(noteLen), ", Ave Var:", variance(noteLen) print "Ave #Lines:", mean(noteLines), ", Ave Var:", variance(noteLines)
def user_mean_dead(userid): global _walk_cache if userid not in _walk_cache: _walk_cache[userid] = userWalk(User.objects.filter(id=userid)[0]) totDays,activeDays,adeadtotal,adeadgained = _walk_cache[userid] #for alive,dead in adeadtotal: print alive,",",dead return ca.make_feature('mean_alive_notes',mean( [dead for alive,dead in adeadtotal ] ))
def user_mean_day_del(userid): global _walk_cache if userid not in _walk_cache: _walk_cache[userid] = userWalk(User.objects.filter(id=userid)[0]) totDays, activeDays, adeadtotal, adeadgained = _walk_cache[userid] return ca.make_feature('mean_del_notes_per_day', mean([dead for alive, dead in adeadgained]))
def user_mean_dead(userid): global _walk_cache if userid not in _walk_cache: _walk_cache[userid] = userWalk(User.objects.filter(id=userid)[0]) totDays, activeDays, adeadtotal, adeadgained = _walk_cache[userid] #for alive,dead in adeadtotal: print alive,",",dead return ca.make_feature('mean_alive_notes', mean([dead for alive, dead in adeadtotal]))
def user_mean_change(userid): global _walk_cache if userid not in _walk_cache: _walk_cache[userid] = userWalk(User.objects.filter(id=userid)[0]) totDays,activeDays,adeadtotal,adeadgained = _walk_cache[userid] delta = [(new - dead) for new,dead in adeadgained] #print [(new,dead) for new,dead in adeadgained] #print delta return ca.make_feature('mean_change', mean(delta))
def user_mean_change(userid): global _walk_cache if userid not in _walk_cache: _walk_cache[userid] = userWalk(User.objects.filter(id=userid)[0]) totDays, activeDays, adeadtotal, adeadgained = _walk_cache[userid] delta = [(new - dead) for new, dead in adeadgained] #print [(new,dead) for new,dead in adeadgained] #print delta return ca.make_feature('mean_change', mean(delta))
def user_mean_day_del(userid): global _walk_cache if userid not in _walk_cache: _walk_cache[userid] = userWalk(User.objects.filter(id=userid)[0]) totDays,activeDays,adeadtotal,adeadgained = _walk_cache[userid] return ca.make_feature('mean_del_notes_per_day',mean([dead for alive,dead in adeadgained ] ))
def var(v): ev = mean(v) return sum([(x-ev)**2 for x in v ])/(1.0*len(v)-1)
def s(counts): print "min:%g max:%g mode:%g mean:%g median:%g var:%g" % (min(counts),max(counts),mode(counts),mean(counts),median(counts),var(counts)) return (min(counts),max(counts),mode(counts),mean(counts),median(counts),var(counts))
def var(v): ev = mean(v) return sum([(x - ev)**2 for x in v]) / (1.0 * len(v) - 1)
def s(counts): print "min:%g max:%g mode:%g mean:%g median:%g var:%g" % ( min(counts), max(counts), mode(counts), mean(counts), median(counts), var(counts)) return (min(counts), max(counts), mode(counts), mean(counts), median(counts), var(counts))