class_docstr: Online Non-Negative Matrix Factorization.
  
  `Renbo Zhao et al :"Online Nonnegative Matrix Factorization with Outliers" <https://arxiv.org/abs/1604.02634>`_
class_docstr_tok: ["Online","Non-Negative","Matrix","Factorization",".","`","Renbo","Zhao","et","al",":","''","Online","Nonnegative","Matrix","Factorization","with","Outliers","''","<","https",":","\/\/arxiv.org\/abs\/1604.02634",">","`","_"]
docstr: Train the model with new documents.
  
  Parameters
  ----------
  corpus : iterable of list of (int, float) or `csc_matrix` with the shape (n_tokens, n_documents)
      Training corpus.
      Can be either iterable of documents, which are lists of `(word_id, word_count)`,
      or a sparse csc matrix of BOWs for each document.
      If not specified, the model is left uninitialized (presumably, to be trained later with `self.train()`).
  chunksize: int, optional
      Number of documents to be used in each training chunk.
  passes: int, optional
      Number of full passes over the training corpus.
      Leave at default `passes=1` if your input is an iterator.
  eval_every: int, optional
      Number of batches after which l2 norm of (v - Wh) is computed. Decreases performance if set too low.
docstr_tok: ["Train","the","model","with","new","documents",".","Parameters","--","--","--","--","--","corpus",":","iterable","of","list","of","(","int",",","float",")","or","`","csc_matrix","`","with","the","shape","(","n_tokens",",","n_documents",")","Training","corpus",".","Can","be","either","iterable","of","documents",",","which","are","lists","of","`","(","word_id",",","word_count",")","`",",","or","a","sparse","csc","matrix","of","BOWs","for","each","document",".","If","not","specified",",","the","model","is","left","uninitialized","(","presumably",",","to","be","trained","later","with","`","self.train","(",")","`",")",".","chunksize",":","int",",","optional","Number","of","documents","to","be","used","in","each","training","chunk",".","passes",":","int",",","optional","Number","of","full","passes","over","the","training","corpus",".","Leave","at","default","`","passes=1","`","if","your","input","is","an","iterator",".","eval_every",":","int",",","optional","Number","of","batches","after","which","l2","norm","of","(","v","-","Wh",")","is","computed",".","Decreases","performance","if","set","too","low","."]
code: def update(
      self, corpus, chunksize=None, passes=None, eval_every=None
  ):
      """Train the model with new documents.
  
      Parameters
      ----------
      corpus : iterable of list of (int, float) or `csc_matrix` with the shape (n_tokens, n_documents)
          Training corpus.
          Can be either iterable of documents, which are lists of `(word_id, word_count)`,
          or a sparse csc matrix of BOWs for each document.
          If not specified, the model is left uninitialized (presumably, to be trained later with `self.train()`).
      chunksize: int, optional
          Number of documents to be used in each training chunk.
      passes: int, optional
          Number of full passes over the training corpus.
          Leave at default `passes=1` if your input is an iterator.
      eval_every: int, optional
          Number of batches after which l2 norm of (v - Wh) is computed. Decreases performance if set too low.
  
      """
      # use parameters given in constructor, unless user explicitly overrode them
      if passes is None:
          passes = self.passes
      if eval_every is None:
          eval_every = self.eval_every
  
      lencorpus = np.inf
  
      if isinstance(corpus, scipy.sparse.csc.csc_matrix):
          lencorpus = corpus.shape[1]
      else:
          try:
              lencorpus = len(corpus)
          except TypeError:
              logger.info("input corpus stream has no len()")
  
      if chunksize is None:
          chunksize = min(lencorpus, self.chunksize)
  
      evalafter = min(lencorpus, (eval_every or 0) * chunksize)
  
      if lencorpus == 0:
          logger.warning("Nmf.update() called with an empty corpus")
          return
  
      if (
          isinstance(corpus, collections.abc.Iterator)
          and self.passes > 1
      ):
          raise ValueError(
              "Corpus is an iterator, only `passes=1` is valid."
          )
  
      logger.info(
          "running NMF training, %s topics, %i passes over the supplied corpus of %s documents, evaluating L2 "
          "norm every %i documents",
          self.num_topics,
          passes,
          "unknown number of" if lencorpus is None else lencorpus,
          evalafter,
      )
  
      chunk_overall_idx = 1
  
      for pass_ in range(passes):
          if isinstance(corpus, scipy.sparse.csc.csc_matrix):
              grouper = (
                  # Older scipy (0.19 etc) throw an error when slicing beyond the actual sparse array dimensions, so
                  # we clip manually with min() here.
                  corpus[
                      :,
                      col_idx : min(
                          corpus.shape[1], col_idx + self.chunksize
                      ),
                  ]
                  for col_idx in range(
                      0, corpus.shape[1], self.chunksize
                  )
              )
          else:
              grouper = utils.grouper(corpus, self.chunksize)
  
          for chunk_idx, chunk in enumerate(grouper):
              if isinstance(corpus, scipy.sparse.csc.csc_matrix):
                  v = chunk[
                      :, self.random_state.permutation(chunk.shape[1])
                  ]
  
                  chunk_len = v.shape[1]
              else:
                  self.random_state.shuffle(chunk)
  
                  v = matutils.corpus2csc(
                      chunk,
                      num_terms=self.num_tokens,
                  )
  
                  chunk_len = len(chunk)
  
              if np.isinf(lencorpus):
                  logger.info(
                      "PROGRESS: pass %i, at document #%i",
                      pass_,
                      chunk_idx * chunksize + chunk_len,
                  )
              else:
                  logger.info(
                      "PROGRESS: pass %i, at document #%i/%i",
                      pass_,
                      chunk_idx * chunksize + chunk_len,
                      lencorpus,
                  )
  
              if self._W is None:
                  # If `self._W` is not set (i.e. the first batch being handled), compute the initial matrix using the
                  # batch mean.
  
                  self._setup(v)
  
              self._h = self._solveproj(
                  v, self._W, h=self._h, v_max=self.v_max
              )
              h = self._h
  
              if eval_every and (
                  ((chunk_idx + 1) * chunksize >= lencorpus)
                  or (chunk_idx + 1) % eval_every == 0
              ):
                  logger.info("L2 norm: %s", self.l2_norm(v))
                  self.print_topics(5)
  
              self.A *= chunk_overall_idx - 1
              self.A += h.dot(h.T)
              self.A /= chunk_overall_idx
  
              self.B *= chunk_overall_idx - 1
              self.B += v.dot(h.T)
              self.B /= chunk_overall_idx
  
              self._solve_w()
  
              chunk_overall_idx += 1
  
              logger.info("W error: %s", self._w_error)
  
imports: import collections.abc
  import logging
  import numpy
  import scipy.sparse
  from scipy.stats import halfnorm
  from gensim import interfaces
  from gensim import matutils
  from gensim import utils
  from gensim.interfaces import TransformedCorpus
  from gensim.models import basemodel, CoherenceModel
  from gensim.models.nmf_pgd import solve_h
label_desc: Use image node_id 12 for calling the Nmf obj's underlying member method code with example usage: obj.update(corpus, chunksize, passes, eval_every) without return types