class_docstr: Distance transformer from aligner.
  
  Behaviour: uses aligner.get_distance on pairs to obtain distance matrix.
  
  Components
  ----------
  aligner: BaseAligner, must implement get_distance method
      if None, distance is equal zero
docstr: Compute distance/kernel matrix.
  
      Core logic
  
  Behaviour: returns pairwise distance/kernel matrix
      between samples in X and X2
          if X2 is not passed, is equal to X
          if X/X2 is a pd.DataFrame and contains non-numeric columns,
              these are removed before computation
  
  Parameters
  ----------
  X: pd.DataFrame of length n, or 2D np.array with n rows
  X2: pd.DataFrame of length m, or 2D np.array with m rows, optional
      default X2 = X
  
  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",".","Core","logic","Behaviour",":","returns","pairwise","distance\/kernel","matrix","between","samples","in","X","and","X2","if","X2","is","not","passed",",","is","equal","to","X","if","X\/X2","is","a","pd.DataFrame","and","contains","non-numeric","columns",",","these","are","removed","before","computation","Parameters","--","--","--","--","--","X",":","pd.DataFrame","of","length","n",",","or","2D","np.array","with","n","rows","X2",":","pd.DataFrame","of","length","m",",","or","2D","np.array","with","m","rows",",","optional","default","X2","=","X","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.
  
          Core logic
  
      Behaviour: returns pairwise distance/kernel matrix
          between samples in X and X2
              if X2 is not passed, is equal to X
              if X/X2 is a pd.DataFrame and contains non-numeric columns,
                  these are removed before computation
  
      Parameters
      ----------
      X: pd.DataFrame of length n, or 2D np.array with n rows
      X2: pd.DataFrame of length m, or 2D np.array with m rows, optional
          default X2 = X
  
      Returns
      -------
      distmat: np.array of shape [n, m]
          (i,j)-th entry contains distance/kernel between X.iloc[i] and X2.iloc[j]
      """
      # find out whether we know that the resulting matrix is symmetric
      #   since aligner distances are always symmetric,
      #   we know it's the case for sure if X equals X2
      if X2 is None:
          X = X2
          symm = True
      else:
          symm = False
  
      n = len(X)
      m = len(X2)
  
      distmat = np.zeros((n, m), dtype="float")
  
      if self.aligner is not None:
          aligner = self.aligner.clone()
      else:
          return distmat
  
      for i in range(n):
          for j in range(m):
              if symm and j < i:
                  distmat[i, j] = distmat[j, i]
              else:
                  distmat[i, j] = aligner.fit(
                      [X[i], X2[j]]
                  ).get_distance()
  
      return distmat
  
imports: import numpy
  from sktime.dists_kernels.base import BasePairwiseTransformerPanel
label_desc: Use image node_id 2 for calling the DistFromAligner obj's underlying member method code with example usage: obj._transform(X, X2) and returns: distmat, distmat