In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [3]:
#import numpy as np
#import matplotlib.pyplot as plt

In [10]:
a = np.loadtxt(open('/Volumes/ExtendedHD/Users/stevo/Workspaces/lm/eval/ngram_probs_2015-02-24/as.txt','rb'),
               dtype={'names': ('ngram', 'o', 'f', 'nf'), 'formats': ('S100','f','f','f')}, delimiter='\t')

In [11]:
plt.plot(a['nf'],'r.')
plt.plot(a['f'],'g.')
plt.plot(a['o'])


Out[11]:
[<matplotlib.lines.Line2D at 0x10f94c1d0>]

In [6]:
print(a[17395])
print(a[17370])
print(a[18399])
print(a[16532])


(b'Computers bald gel\xc3\xb6st we rden', 0.4246000051498413, 0.03957999870181084, 0.0037609999999403954)
(b'zwei sich Page Barry MacDonald', 0.41670000553131104, 0.08620999753475189, 0.007937000133097172)
(b'ohne dem Bundesminister f\xc3\xbcr Bildung', 0.7915999889373779, 0.04236999899148941, 0.3903999924659729)
(b'sprechen und Probleme lo sen', 0.2143000066280365, 0.05925000086426735, 0.0014639999717473984)

In [15]:
b = a['o'] - a['nf']
b[b<0.2] = 0
c = a['f'] - a['o']
c[c<0.2] = 0
i = np.argsort(c)
plt.plot(c[i], 'g.')
plt.plot(b[i], 'r.')


Out[15]:
[<matplotlib.lines.Line2D at 0x10f099b70>]

In [8]:
print(a[i[18544]])
print(a[i[18576]])


(b'wichtige Rolle in unserer Gesellschaft', 0.296099990606308, 0.7131999731063843, 0.07005999982357025)
(b'm\xc3\xbcssen zu einem \xc3\xbcberwiegenden Teil', 0.3409999907016754, 0.8202000260353088, 0.10119999945163727)

In [ ]: