class_docstr: Model for `Latent Semantic Indexing
  <https://en.wikipedia.org/wiki/Latent_semantic_analysis#Latent_semantic_indexing>`_.
  
  The decomposition algorithm is described in `"Fast and Faster: A Comparison of Two Streamed
  Matrix Decomposition Algorithms" <https://arxiv.org/pdf/1102.5597.pdf>`_.
  
  Notes
  -----
  * :attr:`gensim.models.lsimodel.LsiModel.projection.u` - left singular vectors,
  * :attr:`gensim.models.lsimodel.LsiModel.projection.s` - singular values,
  * ``model[training_corpus]`` - right singular vectors (can be reconstructed if needed).
  
  See Also
  --------
  `FAQ about LSI matrices
  <https://github.com/RaRe-Technologies/gensim/wiki/Recipes-&-FAQ#q4-how-do-you-output-the-u-s-vt-matrices-of-lsi>`_.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.test.utils import common_corpus, common_dictionary, get_tmpfile
      >>> from gensim.models import LsiModel
      >>>
      >>> model = LsiModel(common_corpus[:3], id2word=common_dictionary)  # train model
      >>> vector = model[common_corpus[4]]  # apply model to BoW document
      >>> model.add_documents(common_corpus[4:])  # update model with new documents
      >>> tmp_fname = get_tmpfile("lsi.model")
      >>> model.save(tmp_fname)  # save model
      >>> loaded_model = LsiModel.load(tmp_fname)  # load model
class_docstr_tok: ["Model","for","`","Latent","Semantic","Indexing","<","https",":","\/\/en.wikipedia.org\/wiki\/Latent_semantic_analysis","#","Latent_semantic_indexing",">","`","_",".","The","decomposition","algorithm","is","described","in","`","``","Fast","and","Faster",":","A","Comparison","of","Two","Streamed","Matrix","Decomposition","Algorithms","''","<","https",":","\/\/arxiv.org\/pdf\/1102.5597.pdf",">","`","_",".","Notes","--","--","-","*",":","attr",":","`","gensim.models.lsimodel.LsiModel.projection.u","`","-","left","singular","vectors",",","*",":","attr",":","`","gensim.models.lsimodel.LsiModel.projection.s","`","-","singular","values",",","*","``","model","[","training_corpus","]","``","-","right","singular","vectors","(","can","be","reconstructed","if","needed",")",".","See","Also","--","--","--","--","`","FAQ","about","LSI","matrices","<","https",":","\/\/github.com\/RaRe-Technologies\/gensim\/wiki\/Recipes-","&","-FAQ","#","q4-how-do-you-output-the-u-s-vt-matrices-of-lsi",">","`","_",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.test.utils","import","common_corpus",",","common_dictionary",",","get_tmpfile",">",">",">","from","gensim.models","import","LsiModel",">",">",">",">",">",">","model","=","LsiModel","(","common_corpus","[",":3","]",",","id2word=common_dictionary",")","#","train","model",">",">",">","vector","=","model","[","common_corpus","[","4","]","]","#","apply","model","to","BoW","document",">",">",">","model.add_documents","(","common_corpus","[","4",":","]",")","#","update","model","with","new","documents",">",">",">","tmp_fname","=","get_tmpfile","(","``","lsi.model","''",")",">",">",">","model.save","(","tmp_fname",")","#","save","model",">",">",">","loaded_model","=","LsiModel.load","(","tmp_fname",")","#","load","model"]
docstr: Build an LSI model.
  
  Parameters
  ----------
  corpus : {iterable of list of (int, float), scipy.sparse.csc}, optional
      Stream of document vectors or a sparse matrix of shape (`num_documents`, `num_terms`).
  num_topics : int, optional
      Number of requested factors (latent dimensions)
  id2word : dict of {int: str}, optional
      ID to word mapping, optional.
  chunksize :  int, optional
      Number of documents to be used in each training chunk.
  decay : float, optional
      Weight of existing observations relatively to new ones.
  distributed : bool, optional
      If True - distributed mode (parallel execution on several machines) will be used.
  onepass : bool, optional
      Whether the one-pass algorithm should be used for training.
      Pass `False` to force a multi-pass stochastic algorithm.
  power_iters: int, optional
      Number of power iteration steps to be used.
      Increasing the number of power iterations improves accuracy, but lowers performance
  extra_samples : int, optional
      Extra samples to be used besides the rank `k`. Can improve accuracy.
  dtype : type, optional
      Enforces a type for elements of the decomposed matrix.
  random_seed: {None, int}, optional
      Random seed used to initialize the pseudo-random number generator,
      a local instance of numpy.random.RandomState instance.
docstr_tok: ["Build","an","LSI","model",".","Parameters","--","--","--","--","--","corpus",":","{","iterable","of","list","of","(","int",",","float",")",",","scipy.sparse.csc","}",",","optional","Stream","of","document","vectors","or","a","sparse","matrix","of","shape","(","`","num_documents","`",",","`","num_terms","`",")",".","num_topics",":","int",",","optional","Number","of","requested","factors","(","latent","dimensions",")","id2word",":","dict","of","{","int",":","str","}",",","optional","ID","to","word","mapping",",","optional",".","chunksize",":","int",",","optional","Number","of","documents","to","be","used","in","each","training","chunk",".","decay",":","float",",","optional","Weight","of","existing","observations","relatively","to","new","ones",".","distributed",":","bool",",","optional","If","True","-","distributed","mode","(","parallel","execution","on","several","machines",")","will","be","used",".","onepass",":","bool",",","optional","Whether","the","one-pass","algorithm","should","be","used","for","training",".","Pass","`","False","`","to","force","a","multi-pass","stochastic","algorithm",".","power_iters",":","int",",","optional","Number","of","power","iteration","steps","to","be","used",".","Increasing","the","number","of","power","iterations","improves","accuracy",",","but","lowers","performance","extra_samples",":","int",",","optional","Extra","samples","to","be","used","besides","the","rank","`","k","`",".","Can","improve","accuracy",".","dtype",":","type",",","optional","Enforces","a","type","for","elements","of","the","decomposed","matrix",".","random_seed",":","{","None",",","int","}",",","optional","Random","seed","used","to","initialize","the","pseudo-random","number","generator",",","a","local","instance","of","numpy.random.RandomState","instance","."]
code: def __init__(
      self,
      corpus=None,
      num_topics=200,
      id2word=None,
      chunksize=20000,
      decay=1.0,
      distributed=False,
      onepass=True,
      power_iters=P2_EXTRA_ITERS,
      extra_samples=P2_EXTRA_DIMS,
      dtype=np.float64,
      random_seed=None,
  ):
      """Build an LSI model.
  
      Parameters
      ----------
      corpus : {iterable of list of (int, float), scipy.sparse.csc}, optional
          Stream of document vectors or a sparse matrix of shape (`num_documents`, `num_terms`).
      num_topics : int, optional
          Number of requested factors (latent dimensions)
      id2word : dict of {int: str}, optional
          ID to word mapping, optional.
      chunksize :  int, optional
          Number of documents to be used in each training chunk.
      decay : float, optional
          Weight of existing observations relatively to new ones.
      distributed : bool, optional
          If True - distributed mode (parallel execution on several machines) will be used.
      onepass : bool, optional
          Whether the one-pass algorithm should be used for training.
          Pass `False` to force a multi-pass stochastic algorithm.
      power_iters: int, optional
          Number of power iteration steps to be used.
          Increasing the number of power iterations improves accuracy, but lowers performance
      extra_samples : int, optional
          Extra samples to be used besides the rank `k`. Can improve accuracy.
      dtype : type, optional
          Enforces a type for elements of the decomposed matrix.
      random_seed: {None, int}, optional
          Random seed used to initialize the pseudo-random number generator,
          a local instance of numpy.random.RandomState instance.
  
      """
      self.id2word = id2word
      self.num_topics = int(num_topics)
      self.chunksize = int(chunksize)
      self.decay = float(decay)
      if distributed:
          if not onepass:
              logger.warning(
                  "forcing the one-pass algorithm for distributed LSA"
              )
              onepass = True
      self.onepass = onepass
      self.extra_samples, self.power_iters = extra_samples, power_iters
      self.dtype = dtype
      self.random_seed = random_seed
  
      if corpus is None and self.id2word is None:
          raise ValueError(
              "at least one of corpus/id2word must be specified, to establish input space dimensionality"
          )
  
      if self.id2word is None:
          logger.warning(
              "no word id mapping provided; initializing from corpus, assuming identity"
          )
          self.id2word = utils.dict_from_corpus(corpus)
          self.num_terms = len(self.id2word)
      else:
          self.num_terms = 1 + (
              max(self.id2word.keys()) if self.id2word else -1
          )
  
      self.docs_processed = 0
      self.projection = Projection(
          self.num_terms,
          self.num_topics,
          power_iters=self.power_iters,
          extra_dims=self.extra_samples,
          dtype=dtype,
          random_seed=self.random_seed,
      )
  
      self.numworkers = 1
      if not distributed:
          logger.info("using serial LSI version on this node")
          self.dispatcher = None
      else:
          if not onepass:
              raise NotImplementedError(
                  "distributed stochastic LSA not implemented yet; "
                  "run either distributed one-pass, or serial randomized."
              )
          try:
              import Pyro4
  
              dispatcher = Pyro4.Proxy("PYRONAME:gensim.lsi_dispatcher")
              logger.debug(
                  "looking for dispatcher at %s",
                  str(dispatcher._pyroUri),
              )
              dispatcher.initialize(
                  id2word=self.id2word,
                  num_topics=num_topics,
                  chunksize=chunksize,
                  decay=decay,
                  power_iters=self.power_iters,
                  extra_samples=self.extra_samples,
                  distributed=False,
                  onepass=onepass,
              )
              self.dispatcher = dispatcher
              self.numworkers = len(dispatcher.getworkers())
              logger.info(
                  "using distributed version with %i workers",
                  self.numworkers,
              )
          except Exception as err:
              # distributed version was specifically requested, so this is an error state
              logger.error(
                  "failed to initialize distributed LSI (%s)", err
              )
              raise RuntimeError(
                  "failed to initialize distributed LSI (%s)" % err
              )
  
      if corpus is not None:
          start = time.time()
          self.add_documents(corpus)
          self.add_lifecycle_event(
              "created",
              msg=f"trained {self} in {time.time() - start:.2f}s",
          )
  
imports: import logging
  import sys
  import time
  import numpy
  import scipy.linalg
  import scipy.sparse
  from scipy.sparse import sparsetools
  from gensim import interfaces, matutils, utils
  from gensim.models import basemodel
  from gensim.utils import is_empty
label_desc: Use image node_id 1 to create a new LsiModel object from inherited base classes: interfaces, basemodel with example: obj = LsiModel(corpus, num_topics, id2word, chunksize, decay, distributed, onepass, power_iters, extra_samples, dtype, random_seed)