class_docstr: Distance function obtained from a kernel function.
  
  Formal details (for real valued objects, mixed typed rows in analogy):
  Let :math:`k: \mathbb{R}^D \times \mathbb{R}^D\rightarrow \mathbb{R}`
  be the pairwise function in `kernel`, when applied to `D`-vectors.
  `DistFromKernel(dist)` corresponds to the distance function
  :math:`d(x, y) := \sqrt{k(x, x) + k(y, y) - 2 \cdot k(x, y)}`.
  
  It should be noted that if :math:`k` is positive semi-definite,
  then :math:`d` will be a metric and satisfy the triangle inequality.
  
  Parameters
  ----------
  kernel : pairwise transformer of BasePairwiseTransformer scitype, or
      callable np.ndarray (n_samples, nd) x (n_samples, nd) -> (n_samples x n_samples)
class_docstr_tok: ["Distance","function","obtained","from","a","kernel","function",".","Formal","details","(","for","real","valued","objects",",","mixed","typed","rows","in","analogy",")",":","Let",":","math",":","`","k",":","\\mathbb","{","R","}","^D","\\times","\\mathbb","{","R","}","^D\\rightarrow","\\mathbb","{","R","}","`","be","the","pairwise","function","in","`","kernel","`",",","when","applied","to","`","D","`","-vectors",".","`","DistFromKernel","(","dist",")","`","corresponds","to","the","distance","function",":","math",":","`","d","(","x",",","y",")",":","=","\\sqrt","{","k","(","x",",","x",")","+","k","(","y",",","y",")","-","2","\\cdot","k","(","x",",","y",")","}","`",".","It","should","be","noted","that","if",":","math",":","`","k","`","is","positive","semi-definite",",","then",":","math",":","`","d","`","will","be","a","metric","and","satisfy","the","triangle","inequality",".","Parameters","--","--","--","--","--","kernel",":","pairwise","transformer","of","BasePairwiseTransformer","scitype",",","or","callable","np.ndarray","(","n_samples",",","nd",")","x","(","n_samples",",","nd",")","-",">","(","n_samples","x","n_samples",")"]
docstr: Compute distance/kernel matrix.
  
  private _transform containing core logic, called from public transform
  
  Parameters
  ----------
  X: sktime Panel data container
  X2: sktime Panel data container
  
  Returns
  -------
  distmat: np.array of shape [n, m]
      (i,j)-th entry contains distance/kernel between X.iloc[i] and X2.iloc[j]
docstr_tok: ["Compute","distance\/kernel","matrix",".","private","_transform","containing","core","logic",",","called","from","public","transform","Parameters","--","--","--","--","--","X",":","sktime","Panel","data","container","X2",":","sktime","Panel","data","container","Returns","--","--","--","-","distmat",":","np.array","of","shape","[","n",",","m","]","(","i",",","j",")","-th","entry","contains","distance\/kernel","between","X.iloc","[","i","]","and","X2.iloc","[","j","]"]
code: def _transform(self, X, X2=None):
      """Compute distance/kernel matrix.
  
      private _transform containing core logic, called from public transform
  
      Parameters
      ----------
      X: sktime Panel data container
      X2: sktime Panel data container
  
      Returns
      -------
      distmat: np.array of shape [n, m]
          (i,j)-th entry contains distance/kernel between X.iloc[i] and X2.iloc[j]
      """
      kernel = self.kernel
  
      kernelmat = kernel(X, X2)
  
      if isinstance(kernel, BasePairwiseTransformerPanel):
          diagfun = kernel.transform_diag
      else:
          diagfun = _trafo_diag(kernel)
  
      diag1 = diagfun(X)
      if X2 is None:
          diag2 = diag1
      else:
          diag2 = diagfun(X2)
  
      diag1 = np.array(diag1).flatten()
      diag2 = np.array(diag2).flatten()
  
      n, m = kernelmat.shape
  
      mat1 = np.tile(np.expand_dims(diag1, 1), m)
      mat2 = np.tile(np.expand_dims(diag2, 1), n)
      mat2 = mat2.transpose()
  
      distmat = mat1 + mat2 - 2 * kernelmat
      distmat = np.sqrt(np.abs(distmat))
  
      return distmat
  
file_path: sktime/sktime/dists_kernels/dist_to_kern.py
imports: import numpy
  from sktime.dists_kernels.base import BasePairwiseTransformerPanel
label_desc: Use image node_id 2 for calling the DistFromKernel obj's underlying member method code with example usage: obj._transform(X, X2) and returns: distmat