Skip to content

Instantly share code, notes, and snippets.

@psinger
Created May 28, 2015 11:12
Show Gist options
  • Save psinger/5f359032f8e6839d3474 to your computer and use it in GitHub Desktop.
Save psinger/5f359032f8e6839d3474 to your computer and use it in GitHub Desktop.
i_indices = list()
j_indices = list()
values = list()
for i,k in enumerate(states.keys()):
for v in states.keys()[i+1:]:
if something:
i_indices.append(vocab[k])
j_indices.append(vocab[v])
values.append(10)
#symmetric here
shape_matrix = (max(states.itervalues()) + 1, max(states.itervalues()) + 1)
m = csr_matrix((values, (i_indices, j_indices)),
shape=shape_matrix, dtype=np.float64)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment