class_docstr: A general mixture model.
  
  Frequently, data is generated from multiple components. A mixture model
  is a probabilistic model that explicitly models data as having come from
  a set of probability distributions rather than a single one. Usually, the
  abbreviation "GMM" refers to a Gaussian mixture model, but any probability
  distribution or heterogeneous set of distributions can be included in the
  mixture, making it a "general" mixture model.
  
  However, a mixture model itself has all the same theoretical properties as a
  probability distribution because it is one. Hence, it can be used in any
  situation that a simpler distribution could, such as an emission
  distribution for a HMM or a component of a Bayes classifier.
  
  Conversely, many models that are usually thought of as composed of
  probability distributions but distinct from them, e.g. hidden Markov models,
  Markov chains, and Bayesian networks, can in theory be passed into this
  object and incorporated into the mixture.
  
  If the distributions included in the mixture are not initialized, the
  fitting step will first initialize them by running k-means for a small
  number of iterations and fitting the distributions to the clusters that
  are discovered.
  
  
  Parameters
  ----------
  distributions: tuple or list
          A set of distribution objects. These objects do not need to be
          initialized, i.e., can be "Normal()". 
  
  priors: tuple, numpy.ndarray, torch.Tensor, or None. shape=(k,), optional
          The prior probabilities over the given distributions. Default is None.
  
  max_iter: int, optional
          The number of iterations to do in the EM step of fitting the
          distribution. Default is 10.
  
  tol: float, optional
          The threshold at which to stop during fitting when the improvement
          goes under. Default is 0.1.
  
  inertia: float, [0, 1], optional
          Indicates the proportion of the update to apply to the parameters
          during training. When the inertia is 0.0, the update is applied in
          its entirety and the previous parameters are ignored. When the
          inertia is 1.0, the update is entirely ignored and the previous
          parameters are kept, equivalently to if the parameters were frozen.
  
  frozen: bool, optional
          Whether all the parameters associated with this distribution are frozen.
          If you want to freeze individual pameters, or individual values in those
          parameters, you must modify the `frozen` attribute of the tensor or
          parameter directly. Default is False.
  
  check_data: bool, optional
          Whether to check properties of the data and potentially recast it to
          torch.tensors. This does not prevent checking of parameters but can
          slightly speed up computation when you know that your inputs are valid.
          Setting this to False is also necessary for compiling. Default is True.
  
  verbose: bool, optional
          Whether to print the improvement and timings during training.
class_docstr_tok: ["A","general","mixture","model",".","Frequently",",","data","is","generated","from","multiple","components",".","A","mixture","model","is","a","probabilistic","model","that","explicitly","models","data","as","having","come","from","a","set","of","probability","distributions","rather","than","a","single","one",".","Usually",",","the","abbreviation","``","GMM","''","refers","to","a","Gaussian","mixture","model",",","but","any","probability","distribution","or","heterogeneous","set","of","distributions","can","be","included","in","the","mixture",",","making","it","a","``","general","''","mixture","model",".","However",",","a","mixture","model","itself","has","all","the","same","theoretical","properties","as","a","probability","distribution","because","it","is","one",".","Hence",",","it","can","be","used","in","any","situation","that","a","simpler","distribution","could",",","such","as","an","emission","distribution","for","a","HMM","or","a","component","of","a","Bayes","classifier",".","Conversely",",","many","models","that","are","usually","thought","of","as","composed","of","probability","distributions","but","distinct","from","them",",","e.g",".","hidden","Markov","models",",","Markov","chains",",","and","Bayesian","networks",",","can","in","theory","be","passed","into","this","object","and","incorporated","into","the","mixture",".","If","the","distributions","included","in","the","mixture","are","not","initialized",",","the","fitting","step","will","first","initialize","them","by","running","k-means","for","a","small","number","of","iterations","and","fitting","the","distributions","to","the","clusters","that","are","discovered",".","Parameters","--","--","--","--","--","distributions",":","tuple","or","list","A","set","of","distribution","objects",".","These","objects","do","not","need","to","be","initialized",",","i.e.",",","can","be","``","Normal","(",")","''",".","priors",":","tuple",",","numpy.ndarray",",","torch.Tensor",",","or","None",".","shape=","(","k",",",")",",","optional","The","prior","probabilities","over","the","given","distributions",".","Default","is","None",".","max_iter",":","int",",","optional","The","number","of","iterations","to","do","in","the","EM","step","of","fitting","the","distribution",".","Default","is","10.","tol",":","float",",","optional","The","threshold","at","which","to","stop","during","fitting","when","the","improvement","goes","under",".","Default","is","0.1.","inertia",":","float",",","[","0",",","1","]",",","optional","Indicates","the","proportion","of","the","update","to","apply","to","the","parameters","during","training",".","When","the","inertia","is","0.0",",","the","update","is","applied","in","its","entirety","and","the","previous","parameters","are","ignored",".","When","the","inertia","is","1.0",",","the","update","is","entirely","ignored","and","the","previous","parameters","are","kept",",","equivalently","to","if","the","parameters","were","frozen",".","frozen",":","bool",",","optional","Whether","all","the","parameters","associated","with","this","distribution","are","frozen",".","If","you","want","to","freeze","individual","pameters",",","or","individual","values","in","those","parameters",",","you","must","modify","the","`","frozen","`","attribute","of","the","tensor","or","parameter","directly",".","Default","is","False",".","check_data",":","bool",",","optional","Whether","to","check","properties","of","the","data","and","potentially","recast","it","to","torch.tensors",".","This","does","not","prevent","checking","of","parameters","but","can","slightly","speed","up","computation","when","you","know","that","your","inputs","are","valid",".","Setting","this","to","False","is","also","necessary","for","compiling",".","Default","is","True",".","verbose",":","bool",",","optional","Whether","to","print","the","improvement","and","timings","during","training","."]
docstr: Fit the model to optionally weighted examples.
  
  This method implements the core of the learning process. For a
  mixture model, this involves performing EM until the distributions that
  are being fit converge according to the threshold set by `tol`, or
  until the maximum number of iterations has been hit.
  
  This method is largely a wrapper around the `summarize` and
  `from_summaries` methods. It's primary contribution is serving as a
  loop around these functions and to monitor convergence.
  
  
  Parameters
  ----------
  X: list, tuple, numpy.ndarray, torch.Tensor, shape=(-1, self.d)
          A set of examples to evaluate. 
  
  sample_weight: list, tuple, numpy.ndarray, torch.Tensor optional
          A set of weights for the examples. This can be either of shape
          (-1, self.d) or a vector of shape (-1,). Default is ones.
  
  priors: list, numpy.ndarray, torch.Tensor, shape=(-1, self.k)
          Prior probabilities of assigning each symbol to each node. If not
          provided, do not include in the calculations (conceptually
          equivalent to a uniform probability, but without scaling the
          probabilities). This can be used to assign labels to observatons
          by setting one of the probabilities for an observation to 1.0.
          This can be used when only some labels are known by using a
          uniform distribution when the labels are not known. Note that 
          this can be used to assign hard labels, but does not have the 
          same semantics for soft labels, in that it only influences the 
          initial estimate of an observation being generated by a component, 
          not gives a target. Default is None.
  
  
  Returns
  -------
  self
docstr_tok: ["Fit","the","model","to","optionally","weighted","examples",".","This","method","implements","the","core","of","the","learning","process",".","For","a","mixture","model",",","this","involves","performing","EM","until","the","distributions","that","are","being","fit","converge","according","to","the","threshold","set","by","`","tol","`",",","or","until","the","maximum","number","of","iterations","has","been","hit",".","This","method","is","largely","a","wrapper","around","the","`","summarize","`","and","`","from_summaries","`","methods",".","It","'s","primary","contribution","is","serving","as","a","loop","around","these","functions","and","to","monitor","convergence",".","Parameters","--","--","--","--","--","X",":","list",",","tuple",",","numpy.ndarray",",","torch.Tensor",",","shape=","(","-1",",","self.d",")","A","set","of","examples","to","evaluate",".","sample_weight",":","list",",","tuple",",","numpy.ndarray",",","torch.Tensor","optional","A","set","of","weights","for","the","examples",".","This","can","be","either","of","shape","(","-1",",","self.d",")","or","a","vector","of","shape","(","-1",",",")",".","Default","is","ones",".","priors",":","list",",","numpy.ndarray",",","torch.Tensor",",","shape=","(","-1",",","self.k",")","Prior","probabilities","of","assigning","each","symbol","to","each","node",".","If","not","provided",",","do","not","include","in","the","calculations","(","conceptually","equivalent","to","a","uniform","probability",",","but","without","scaling","the","probabilities",")",".","This","can","be","used","to","assign","labels","to","observatons","by","setting","one","of","the","probabilities","for","an","observation","to","1.0",".","This","can","be","used","when","only","some","labels","are","known","by","using","a","uniform","distribution","when","the","labels","are","not","known",".","Note","that","this","can","be","used","to","assign","hard","labels",",","but","does","not","have","the","same","semantics","for","soft","labels",",","in","that","it","only","influences","the","initial","estimate","of","an","observation","being","generated","by","a","component",",","not","gives","a","target",".","Default","is","None",".","Returns","--","--","--","-","self"]
code: def fit(self, X, sample_weight=None, priors=None):
      """Fit the model to optionally weighted examples.
  
      This method implements the core of the learning process. For a
      mixture model, this involves performing EM until the distributions that
      are being fit converge according to the threshold set by `tol`, or
      until the maximum number of iterations has been hit.
  
      This method is largely a wrapper around the `summarize` and
      `from_summaries` methods. It's primary contribution is serving as a
      loop around these functions and to monitor convergence.
  
  
      Parameters
      ----------
      X: list, tuple, numpy.ndarray, torch.Tensor, shape=(-1, self.d)
              A set of examples to evaluate.
  
      sample_weight: list, tuple, numpy.ndarray, torch.Tensor optional
              A set of weights for the examples. This can be either of shape
              (-1, self.d) or a vector of shape (-1,). Default is ones.
  
      priors: list, numpy.ndarray, torch.Tensor, shape=(-1, self.k)
              Prior probabilities of assigning each symbol to each node. If not
              provided, do not include in the calculations (conceptually
              equivalent to a uniform probability, but without scaling the
              probabilities). This can be used to assign labels to observatons
              by setting one of the probabilities for an observation to 1.0.
              This can be used when only some labels are known by using a
              uniform distribution when the labels are not known. Note that
              this can be used to assign hard labels, but does not have the
              same semantics for soft labels, in that it only influences the
              initial estimate of an observation being generated by a component,
              not gives a target. Default is None.
  
  
      Returns
      -------
      self
      """
  
      logp = None
      for i in range(self.max_iter):
          start_time = time.time()
  
          last_logp = logp
          logp = self.summarize(
              X, sample_weight=sample_weight, priors=priors
          )
  
          if i > 0:
              improvement = logp - last_logp
              duration = time.time() - start_time
  
              if self.verbose:
                  print(
                      "[{}] Improvement: {}, Time: {:4.4}s".format(
                          i, improvement, duration
                      )
                  )
  
              if improvement < self.tol:
                  break
  
          self.from_summaries()
  
      self._reset_cache()
      return self
  
file_path: pomegranate/pomegranate/gmm.py
imports: import time
  import numpy
  import torch
  from ._utils import _cast_as_tensor
  from ._utils import _cast_as_parameter
  from ._utils import _update_parameter
  from ._utils import _check_parameter
  from ._utils import _reshape_weights
  from .distributions._distribution import Distribution
  from ._bayes import BayesMixin
  from .kmeans import KMeans
label_desc: Use image node_id 4 for calling the GeneralMixtureModel obj's underlying member method code with example usage: obj.fit(X, sample_weight, priors) and returns: self