def create_expanded_model(Data, curModel, \
                          curLP=None, curSS=None, allSS=None, **kwargs):
  Kfresh = kwargs['Kfresh']
  Korig = curModel.obsModel.K

  if kwargs['creationroutine'].count('datadriven'):
    topics = create_critical_need_topics(Data, curModel, curLP, 
                                          allSS=allSS, **kwargs)
  elif kwargs['creationroutine'] == 'fromtargetstats':
    ''' Similar to Mike Bryant's style proposal
    '''
    if Kfresh <= Korig:
      topicIDs = kwargs['randstate'].choice(Korig, Kfresh, replace=False)
    else:
      topicIDs = kwargs['randstate'].choice(Korig, Kfresh, replace=True)
    topics = curSS.WordCounts[topicIDs,:]
    topics += curModel.obsModel.obsPrior.lamvec
    topics /= topics.sum(axis=1)[:,np.newaxis]

    # Draw random perturbations
    uniftopics = kwargs['randstate'].rand(Kfresh, Data.vocab_size)
    uniftopics /= uniftopics.sum(axis=1)[:,np.newaxis]
    
    topics = 0.95 * topics + 0.05 * uniftopics

  elif kwargs['creationroutine'] == 'randomfromexisting':
    # Select Kfresh topics from current set, at random
    topics = np.exp(curModel.obsModel.getElogphiMatrix())
    if Kfresh <= Korig:
      rowIDs = kwargs['randstate'].choice(Korig, Kfresh, replace=False)
    else:
      rowIDs = kwargs['randstate'].choice(Korig, Kfresh, replace=True)
    topics = topics[rowIDs]
    topics /= topics.sum(axis=1)[:,np.newaxis]

    # Draw random perturbations
    uniftopics = kwargs['randstate'].rand(Kfresh, Data.vocab_size)
    uniftopics /= uniftopics.sum(axis=1)[:,np.newaxis]
    
    topics = 0.9 * topics + 0.1 * uniftopics

  elif kwargs['creationroutine'] == 'randomfromprior':
    topics = kwargs['randstate'].gamma(curModel.obsModel.obsPrior.lamvec, 1.0, 
                                       (Kfresh, Data.vocab_size))
    topics = np.maximum(topics, 1e-6)
    topics /= topics.sum(axis=1)[:,np.newaxis]
  else:
    msg = "Unrecognised creationroutine: %s" % (kwargs['creationroutine'])
    raise NotImplementedError(msg)

  freshModel = curModel.copy()
  freshModel.set_global_params(beta=np.ones(Kfresh)/Kfresh, K=Kfresh,
                                    topics=topics
                                   )
  freshLP = freshModel.calc_local_params(Data)
  freshSS = freshModel.get_global_suff_stats(Data, freshLP)

  expandSS = allSS.copy()
  expandModel = curModel.copy()

  expandSS.insertComps(freshSS)
  expandModel.update_global_params(expandSS)

  assert expandModel.allocModel.K == Korig + Kfresh
  assert expandModel.obsModel.K == Korig + Kfresh
  return expandModel
Emulate wx.Timer.
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/learnalg/BirthMoveTopicModel.py/create_expanded_model--crossover with--dataset/ETHPy150Open enthought/pyface/pyface/ui/qt4/timer/timer.py/Timer.IsRunning