original_docstring:  Returns matrix of candidate topic-word parameters for each of n Plans
      
docstring: Returns matrix of candidate topic-word parameters for each of n Plans
docstring_tokens: Returns matrix of candidate topic - word parameters for each of n Plans
code: def makeCandidateTopics_MissingTopic(Data, model, LP, nPlans=1,
                                       seed=0, **kwargs):
      ''' Returns matrix of candidate topic-word parameters for each of n Plans
      '''
      import KMeansRex
      ScoreMat = calcDocWordUnderpredictionScores(Data, model, LP)
  
      # Condense to one scalar per doc,
      #  where higher value => more distance between Model and Emp
      AScorePerDoc = np.sum(np.abs(ScoreMat), axis=1)
  
      # Keep only the worst 10% of all docs,
      nKeep = np.maximum(int(0.1 * Data.nDoc), 50)
      keepIDs = np.argsort(-1 * AScorePerDoc)[:nKeep]
  
      ScoreMat = ScoreMat[keepIDs]
      ScoreMat = np.maximum(0, ScoreMat)
      ScoreMat /= ScoreMat.sum(axis=1)[:, np.newaxis]
  
      K = np.maximum(nPlans, 2)
      newTopics, Z = KMeansRex.RunKMeans(ScoreMat, K,
                                         initname='plusplus',
                                         Niter=10, seed=seed)
  
      # Remove uncommon candidates (based on very little data)
      Nk, binedges = np.histogram(np.squeeze(Z), np.arange(-0.5, K))
      newTopics = newTopics[Nk >= 5]
      Nk = Nk[Nk >= 5]
  
      if nPlans < newTopics.shape[0]:
          newTopics = newTopics[np.argmax(Nk)]
  
      if newTopics.ndim == 1:
          newTopics = newTopics[np.newaxis, :]
  
      # Normalize and return
      newTopics = np.maximum(1e-8, newTopics)
      newTopics /= newTopics.sum(axis=1)[:, np.newaxis]
      return newTopics, dict(Nk=Nk)
code_tokens: def makeCandidateTopics_MissingTopic ( Data , model , LP , nPlans = 1 , seed = 0 , ** kwargs ) : import KMeansRex ScoreMat = calcDocWordUnderpredictionScores ( Data , model , LP ) AScorePerDoc = np . sum ( np . abs ( ScoreMat ) , axis = 1 ) nKeep = np . maximum ( int ( 0.1 * Data . nDoc ) , 50 ) keepIDs = np . argsort ( - 1 * AScorePerDoc ) [ : nKeep ] ScoreMat = ScoreMat [ keepIDs ] ScoreMat = np . maximum ( 0 , ScoreMat ) ScoreMat /= ScoreMat . sum ( axis = 1 ) [ : , np . newaxis ] K = np . maximum ( nPlans , 2 ) newTopics , Z = KMeansRex . RunKMeans ( ScoreMat , K , initname = 'plusplus' , Niter = 10 , seed = seed ) Nk , binedges = np . histogram ( np . squeeze ( Z ) , np . arange ( - 0.5 , K ) ) newTopics = newTopics [ Nk >= 5 ] Nk = Nk [ Nk >= 5 ] if nPlans < newTopics . shape [ 0 ] : newTopics = newTopics [ np . argmax ( Nk ) ] if newTopics . ndim == 1 : newTopics = newTopics [ np . newaxis , : ] newTopics = np . maximum ( 1e-8 , newTopics ) newTopics /= newTopics . sum ( axis = 1 ) [ : , np . newaxis ] return newTopics , dict ( Nk = Nk )
short_docstring: Returns matrix of candidate topic-word parameters for each of n Plans
short_docstring_tokens: Returns matrix of candidate topic - word parameters for each of n Plans
comment: ''' Returns matrix of candidate topic-word parameters for each of n Plans
      '''$SEP$# Condense to one scalar per doc,$SEP$#  where higher value => more distance between Model and Emp$SEP$# Keep only the worst 10% of all docs,$SEP$# Remove uncommon candidates (based on very little data)$SEP$# Normalize and return