def makeFigure(hmmKappa=0):
Data, trueResp = makeDataAndTrueResp()
kemptyVals = np.asarray([0, 1, 2, 3.])
ELBOVals = np.zeros_like(kemptyVals, dtype=np.float)
# Iterate over the number of empty states (0, 1, 2, ...)
for ii, kempty in enumerate(kemptyVals):
resp = makeNewRespWithEmptyStates(trueResp, kempty)
ELBOVals[ii] = resp2ELBO_HDPHMM(Data, resp, hmmKappa=hmmKappa)
# Make largest value the one with kempty=0, to make plot look good
ELBOVals -= ELBOVals[0]
# Plot the results
from matplotlib import pylab
figH = pylab.figure(figsize=(6, 4))
plotargs = dict(markersize=10, linewidth=3)
pylab.plot(kemptyVals, ELBOVals, 'o--', label='HDP surrogate',
color='b', markeredgecolor='b',
**plotargs)
pylab.xlabel('num. empty topics', fontsize=20)
pylab.ylabel('change in ELBO', fontsize=20)
B = 0.25
pylab.xlim([-B, kemptyVals[-1] + B])
pylab.xticks(kemptyVals)
axH = pylab.gca()
axH.tick_params(axis='both', which='major', labelsize=15)
legH = pylab.legend(loc='upper left', prop={'size': 15})
figH.subplots_adjust(bottom=0.16, left=0.2)
pylab.show(block=True)
评论列表
文章目录