def show_many_random_initial_models(
obsPriorArgsDict,
initArgsDict,
nrows=1, ncols=6):
''' Create plot of many different random initializations
'''
fig_handle, ax_handle_list = pylab.subplots(
figsize=(SMALL_FIG_SIZE[0] * ncols, SMALL_FIG_SIZE[1] * nrows),
nrows=nrows, ncols=ncols, sharex=True, sharey=True)
for trial_id in range(nrows * ncols):
cur_model = bnpy.make_initialized_model(
dataset,
allocModelName='FiniteMixtureModel',
obsModelName='Gauss',
algName='VB',
allocPriorArgsDict=dict(gamma=10.0),
obsPriorArgsDict=obsPriorArgsDict,
initArgsDict=initArgsDict,
seed=int(trial_id),
)
# Plot the current model
cur_ax_handle = ax_handle_list.flatten()[trial_id]
bnpy.viz.PlotComps.plotCompsFromHModel(
cur_model, Data=dataset, ax_handle=cur_ax_handle)
cur_ax_handle.set_xticks([-2, -1, 0, 1, 2])
cur_ax_handle.set_yticks([-2, -1, 0, 1, 2])
pylab.tight_layout()
###############################################################################
# initname: 'randexamples'
# ------------------------
# This procedure selects K examples uniformly at random.
# Each cluster is then initialized from one selected example,
# using a standard global step update.
#
# **Example 1**:
# Initialize with 8 clusters, with prior biased towards small covariances
#
# .. math::
#
# \E_{\mbox{prior}}[ \Sigma_k ] = 0.01 I_D
plot-01-demo=init_methods-model=mix+gauss.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录