code: def _smacof_single(
      similarities,
      metric=True,
      n_components=2,
      init=None,
      max_iter=300,
      verbose=0,
      eps=1e-3,
      random_state=None,
  ):
      """
      Computes multidimensional scaling using SMACOF algorithm
  
      Parameters
      ----------
      similarities: symmetric ndarray, shape [n * n]
          similarities between the points
  
      metric: boolean, optional, default: True
          compute metric or nonmetric SMACOF algorithm
  
      n_components: int, optional, default: 2
          number of dimension in which to immerse the similarities
          overwritten if initial array is provided.
  
      init: {None or ndarray}, optional
          if None, randomly chooses the initial configuration
          if ndarray, initialize the SMACOF algorithm with this array
  
      max_iter: int, optional, default: 300
          Maximum number of iterations of the SMACOF algorithm for a single run
  
      verbose: int, optional, default: 0
          level of verbosity
  
      eps: float, optional, default: 1e-6
          relative tolerance w.r.t stress to declare converge
  
      random_state: integer or numpy.RandomState, optional
          The generator used to initialize the centers. If an integer is
          given, it fixes the seed. Defaults to the global numpy random
          number generator.
  
      Returns
      -------
      X: ndarray (n_samples, n_components), float
                 coordinates of the n_samples points in a n_components-space
  
      stress_: float
          The final value of the stress (sum of squared distance of the
          disparities and the distances for all constrained points)
  
      n_iter : int
          Number of iterations run.
  
      """
      similarities = check_symmetric(similarities, raise_exception=True)
  
      n_samples = similarities.shape[0]
      random_state = check_random_state(random_state)
  
      sim_flat = ((1 - np.tri(n_samples)) * similarities).ravel()
      sim_flat_w = sim_flat[sim_flat != 0]
      if init is None:
          # Randomly choose initial configuration
          X = random_state.rand(n_samples * n_components)
          X = X.reshape((n_samples, n_components))
      else:
          # overrides the parameter p
          n_components = init.shape[1]
          if n_samples != init.shape[0]:
              raise ValueError(
                  "init matrix should be of shape (%d, %d)"
                  % (n_samples, n_components)
              )
          X = init
  
      old_stress = None
      ir = IsotonicRegression()
      for it in range(max_iter):
          # Compute distance and monotonic regression
          dis = euclidean_distances(X)
  
          if metric:
              disparities = similarities
          else:
              dis_flat = dis.ravel()
              # similarities with 0 are considered as missing values
              dis_flat_w = dis_flat[sim_flat != 0]
  
              # Compute the disparities using a monotonic regression
              disparities_flat = ir.fit_transform(
                  sim_flat_w, dis_flat_w
              )
              disparities = dis_flat.copy()
              disparities[sim_flat != 0] = disparities_flat
              disparities = disparities.reshape((n_samples, n_samples))
              disparities *= np.sqrt(
                  (n_samples * (n_samples - 1) / 2)
                  / (disparities**2).sum()
              )
  
          # Compute stress
          stress = ((dis.ravel() - disparities.ravel()) ** 2).sum() / 2
  
          # Update X using the Guttman transform
          dis[dis == 0] = 1e-5
          ratio = disparities / dis
          B = -ratio
          B[np.arange(len(B)), np.arange(len(B))] += ratio.sum(axis=1)
          X = 1.0 / n_samples * np.dot(B, X)
  
          dis = np.sqrt((X**2).sum(axis=1)).sum()
          if verbose >= 2:
              print("it: %d, stress %s" % (it, stress))
          if old_stress is not None:
              if (old_stress - stress / dis) < eps:
                  if verbose:
                      print(
                          "breaking at iteration %d with stress %s"
                          % (it, stress)
                      )
                  break
          old_stress = stress / dis
  
      return X, stress, it + 1
  
file_path: catboost/contrib/python/scikit-learn/py2/sklearn/manifold/mds.py
imports: import numpy
  import warnings
  from ..base import BaseEstimator
  from ..metrics import euclidean_distances
  from ..utils import check_random_state, check_array, check_symmetric
  from ..externals.joblib import Parallel
  from ..externals.joblib import delayed
  from ..isotonic import IsotonicRegression
label_desc: Use image node_id 1 for calling a global function with example usage: _smacof_single(similarities, metric, n_components, init, max_iter, verbose, eps, random_state) and returns: X,  stress,  unknown