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

Function plot_matrices

numpy_ml/plots/hmm_plots.py:58–127  ·  view source on GitHub ↗
(params, best, best_theirs)

Source from the content-addressed store, hash-verified

56
57
58def plot_matrices(params, best, best_theirs):
59 cmap = "copper"
60 ll_mine, best = best
61 ll_theirs, best_theirs = best_theirs
62
63 fig, axes = plt.subplots(3, 3)
64 axes = {
65 "A": [axes[0, 0], axes[0, 1], axes[0, 2]],
66 "B": [axes[1, 0], axes[1, 1], axes[1, 2]],
67 "pi": [axes[2, 0], axes[2, 1], axes[2, 2]],
68 }
69
70 for k, tt in [("A", "Transition"), ("B", "Emission"), ("pi", "Prior")]:
71 true_ax, est_ax, est_theirs_ax = axes[k]
72 true, est, est_theirs = params[k], best[k], best_theirs[k]
73
74 if k == "pi":
75 true = true.reshape(-1, 1)
76 est = est.reshape(-1, 1)
77 est_theirs = est_theirs.reshape(-1, 1)
78
79 true_ax = sns.heatmap(
80 true,
81 vmin=0.0,
82 vmax=1.0,
83 fmt=".2f",
84 cmap=cmap,
85 cbar=False,
86 annot=True,
87 ax=true_ax,
88 xticklabels=[],
89 yticklabels=[],
90 linewidths=0.25,
91 )
92
93 est_ax = sns.heatmap(
94 est,
95 vmin=0.0,
96 vmax=1.0,
97 fmt=".2f",
98 ax=est_ax,
99 cmap=cmap,
100 annot=True,
101 cbar=False,
102 xticklabels=[],
103 yticklabels=[],
104 linewidths=0.25,
105 )
106
107 est_theirs_ax = sns.heatmap(
108 est_theirs,
109 vmin=0.0,
110 vmax=1.0,
111 fmt=".2f",
112 cmap=cmap,
113 annot=True,
114 cbar=False,
115 xticklabels=[],

Callers 1

test_HMMFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_HMMFunction · 0.68