Skip to content

Instantly share code, notes, and snippets.

@TomHortons
Created July 18, 2017 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TomHortons/68023b27e469bdb25e0249477ba9f123 to your computer and use it in GitHub Desktop.
Save TomHortons/68023b27e469bdb25e0249477ba9f123 to your computer and use it in GitHub Desktop.
# Co-occurence Matrix
com = np.zeros([len(counts)]*2)
for i, l in enumerate(list(counts.keys())):
for i2, l2 in enumerate(list(counts.keys())):
c = 0
cy = 0
for row in labels.values:
if l in row:
c += 1
if l2 in row: cy += 1
com[i, i2] = cy / c
data=[go.Heatmap(z=com, x=list(counts.keys()), y=list(counts.keys()))]
layout=go.Layout(height=800, width=800, title='Co-occurence matrix of training labels')
fig=dict(data=data, layout=layout)
py.iplot(data, filename='train-com')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment