Skip to content

Instantly share code, notes, and snippets.

@dcrystalj
Created November 14, 2013 13:24
Show Gist options
  • Save dcrystalj/7466724 to your computer and use it in GitHub Desktop.
Save dcrystalj/7466724 to your computer and use it in GitHub Desktop.
predict
from snap import *
import collections
FILENAME = 'FSlearn.csv'
def getNeighbors(G, i):
neighborsV = TIntV()
GetNodesAtHop(G, i, 1, neighborsV, False)
return [i for i in neighborsV]
def maxPlace(places):
maxi = 0
maxj = 0
for i,j in places:
if i > maxi:
maxi = i
maxj = j
FInf = TFIn(FILENAME + 'predictions.bin')
Gf = TNEANet.Load(FInf)
nodes = [i.GetId() for i in G.Nodes()]
people = [i for i in nodes if i>0]
locations = [i for i in nodes if i<-1]
human = collections.defaultdict(lambda: [])
for i in locations:
herd = Gf.GetIntAttrDatN(j, "herd")
tail = Gf.GetIntAttrDatN(j, "tail")
for j in people:
friend = 0
if G.IsEdge(i,j):
friend += (Gf.GetIntAttrDatE( Gf.GetEId(i, j), "checkin" ) #todo checkin v friend
human[j].append( (i, herd+tail+friend) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment