class_docstr: Compute affinities using nearest neighbors and a fixed bandwidth
  for the Gaussians in the ambient space.
  
  Using a fixed Gaussian bandwidth can enable us to find smaller clusters of
  data points than we might be able to using the automatically determined
  bandwidths using perplexity. Note however that this requires mostly trial
  and error.
  
  Parameters
  ----------
  data: np.ndarray
      The data matrix.
  
  sigma: float
      The bandwidth to use for the Gaussian kernels in the ambient space.
  
  k: int
      The number of nearest neighbors to consider for each kernel.
  
  method: str
      Specifies the nearest neighbor method to use. Can be ``exact``, ``annoy``,
      ``pynndescent``, ``hnsw``, ``approx``, or ``auto`` (default). ``approx``
      uses Annoy if the input data matrix is not a sparse object and if Annoy
      supports the given metric. Otherwise, it uses Pynndescent. ``auto`` uses
      exact nearest neighbors for N<1000 and the same heuristic as ``approx``
      for N>=1000.
  
  metric: Union[str, Callable]
      The metric to be used to compute affinities between points in the
      original space.
  
  metric_params: dict
      Additional keyword arguments for the metric function.
  
  symmetrize: bool
      Symmetrize the affinity matrix. During standard t-SNE optimization, the
      affinities are symmetrized. However, when embedding new data points into
      existing embeddings, symmetrization is not performed.
  
  n_jobs: int
      The number of threads to use while running t-SNE. This follows the
      scikit-learn convention, ``-1`` meaning all processors, ``-2`` meaning
      all but one, etc.
  
  random_state: Union[int, RandomState]
      If the value is an int, random_state is the seed used by the random
      number generator. If the value is a RandomState instance, then it will
      be used as the random number generator. If the value is None, the random
      number generator is the RandomState instance used by `np.random`.
  
  verbose: bool
  
  knn_index: Optional[nearest_neighbors.KNNIndex]
      Optionally, a precomptued ``openTSNE.nearest_neighbors.KNNIndex`` object
      can be specified. This option will ignore any KNN-related parameters.
      When ``knn_index`` is specified, ``data`` must be set to None.
class_docstr_tok: ["Compute","affinities","using","nearest","neighbors","and","a","fixed","bandwidth","for","the","Gaussians","in","the","ambient","space",".","Using","a","fixed","Gaussian","bandwidth","can","enable","us","to","find","smaller","clusters","of","data","points","than","we","might","be","able","to","using","the","automatically","determined","bandwidths","using","perplexity",".","Note","however","that","this","requires","mostly","trial","and","error",".","Parameters","--","--","--","--","--","data",":","np.ndarray","The","data","matrix",".","sigma",":","float","The","bandwidth","to","use","for","the","Gaussian","kernels","in","the","ambient","space",".","k",":","int","The","number","of","nearest","neighbors","to","consider","for","each","kernel",".","method",":","str","Specifies","the","nearest","neighbor","method","to","use",".","Can","be","``","exact","``",",","``","annoy","``",",","``","pynndescent","``",",","``","hnsw","``",",","``","approx","``",",","or","``","auto","``","(","default",")",".","``","approx","``","uses","Annoy","if","the","input","data","matrix","is","not","a","sparse","object","and","if","Annoy","supports","the","given","metric",".","Otherwise",",","it","uses","Pynndescent",".","``","auto","``","uses","exact","nearest","neighbors","for","N","<","1000","and","the","same","heuristic","as","``","approx","``","for","N",">","=1000",".","metric",":","Union","[","str",",","Callable","]","The","metric","to","be","used","to","compute","affinities","between","points","in","the","original","space",".","metric_params",":","dict","Additional","keyword","arguments","for","the","metric","function",".","symmetrize",":","bool","Symmetrize","the","affinity","matrix",".","During","standard","t-SNE","optimization",",","the","affinities","are","symmetrized",".","However",",","when","embedding","new","data","points","into","existing","embeddings",",","symmetrization","is","not","performed",".","n_jobs",":","int","The","number","of","threads","to","use","while","running","t-SNE",".","This","follows","the","scikit-learn","convention",",","``","-1","``","meaning","all","processors",",","``","-2","``","meaning","all","but","one",",","etc",".","random_state",":","Union","[","int",",","RandomState","]","If","the","value","is","an","int",",","random_state","is","the","seed","used","by","the","random","number","generator",".","If","the","value","is","a","RandomState","instance",",","then","it","will","be","used","as","the","random","number","generator",".","If","the","value","is","None",",","the","random","number","generator","is","the","RandomState","instance","used","by","`","np.random","`",".","verbose",":","bool","knn_index",":","Optional","[","nearest_neighbors.KNNIndex","]","Optionally",",","a","precomptued","``","openTSNE.nearest_neighbors.KNNIndex","``","object","can","be","specified",".","This","option","will","ignore","any","KNN-related","parameters",".","When","``","knn_index","``","is","specified",",","``","data","``","must","be","set","to","None","."]
code: def __init__(
      self,
      data=None,
      sigma=None,
      k=30,
      method="auto",
      metric="euclidean",
      metric_params=None,
      symmetrize=True,
      n_jobs=1,
      random_state=None,
      verbose=False,
      knn_index=None,
  ):
      # Sigma must be specified, but has default set to none, so the parameter
      # order makes more sense
      if sigma is None:
          raise ValueError("`sigma` must be specified!")
  
      # This can't work if neither data nor the knn index are specified
      if data is None and knn_index is None:
          raise ValueError(
              "At least one of the parameters `data` or `knn_index` must be specified!"
          )
      # This can't work if both data and the knn index are specified
      if data is not None and knn_index is not None:
          raise ValueError(
              "Both `data` or `knn_index` were specified! Please pass only one."
          )
  
      # Find the nearest neighbors
      if knn_index is None:
          if k >= data.shape[0]:
              raise ValueError(
                  "`k` (%d) cannot be larger than N-1 (%d)."
                  % (k, data.shape[0])
              )
  
          self.knn_index = get_knn_index(
              data,
              method,
              k,
              metric,
              metric_params,
              n_jobs,
              random_state,
              verbose,
          )
  
      else:
          self.knn_index = knn_index
          log.info(
              "KNN index provided. Ignoring KNN-related parameters."
          )
  
      neighbors, distances = self.knn_index.build()
  
      with utils.Timer("Calculating affinity matrix...", verbose):
          # Compute asymmetric pairwise input similarities
          conditional_P = np.exp(-(distances**2) / (2 * sigma**2))
          conditional_P /= np.sum(conditional_P, axis=1)[:, np.newaxis]
  
          n_samples = self.knn_index.n_samples
          P = sp.csr_matrix(
              (
                  conditional_P.ravel(),
                  neighbors.ravel(),
                  range(0, n_samples * k + 1, k),
              ),
              shape=(n_samples, n_samples),
          )
  
          # Symmetrize the probability matrix
          if symmetrize:
              P = (P + P.T) / 2
  
          # Convert weights to probabilities
          P /= np.sum(P)
  
      self.sigma = sigma
      self.P = P
      self.n_jobs = n_jobs
      self.verbose = verbose
  
imports: import logging
  import numbers
  import operator
  from functools import reduce
  import numpy
  import scipy.sparse
  from openTSNE import _tsne
  from openTSNE import nearest_neighbors
  from openTSNE import utils
  from openTSNE.utils import is_package_installed
  import warnings
label_desc: Use image node_id 1 to create a new FixedSigmaNN object from inherited base classes: Affinities with example: obj = FixedSigmaNN(data, sigma, k, method, metric, metric_params, symmetrize, n_jobs, random_state, verbose, knn_index)