MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / plot_count_models

Function plot_count_models

numpy_ml/plots/ngram_plots.py:15–28  ·  view source on GitHub ↗
(GT, N)

Source from the content-addressed store, hash-verified

13
14
15def plot_count_models(GT, N):
16 NC = GT._num_grams_with_count
17 mod = GT._count_models[N]
18 max_n = max(GT.counts[N].values())
19 emp = [NC(n + 1, N) for n in range(max_n)]
20 prd = [np.exp(mod.predict(np.array([n + 1]))) for n in range(max_n + 10)]
21 plt.scatter(range(max_n), emp, c="r", label="actual")
22 plt.plot(range(max_n + 10), prd, "-", label="model")
23 plt.ylim([-1, 100])
24 plt.xlabel("Count ($r$)")
25 plt.ylabel("Count-of-counts ($N_r$)")
26 plt.legend()
27 plt.savefig("test.png")
28 plt.close()
29
30
31def compare_probs(fp, N):

Callers

nothing calls this directly

Calls 1

predictMethod · 0.45

Tested by

no test coverage detected