class_docstr: Panel distance from tabular distance aggregation.
  
  panel distance obtained by applying aggregation function to tabular distance matrix
      example: AggrDist(ScipyDist()) is mean Euclidean distance between series
  
  Formal details (for real valued objects, mixed typed rows in analogy):
  Let :math:`d: \mathbb{R}^k \times \mathbb{R}^{k}\rightarrow \mathbb{R}`
  be the pairwise function in `transformer`, when applied to `k`-vectors.
  Let :math:`f:\mathbb{R}^{n \ times m}` be the function `aggfunc` when applied to
  an :math:`(n \times m)` matrix.
  Let :math:`x_1, \dots, x_N\in \mathbb{R}^{n \times k}`,
  :math:`y_1, \dots y_M \in \mathbb{R}^{m \times k}` be collections of matrices,
  representing time series panel valued inputs `X` and `X2`, as follows:
  :math:`x_i` is the `i`-th instance in `X`, and :math:`x_{i, j\ell}` is the
  `j`-th time point, `\ell`-th variable of `X`. Analogous for :math:`y` and `X2`.
  
  Then, `transform(X, X2)` returns the :math:`(N \times M)` matrix
  with :math:`(i, j)`-th entry :math:`f \left((d(x_{i, a}, y_{j, b}))_{a, b}\right)`,
  where :math:`x_{i, a}` denotes the :math:`a`-th row of :math:`x_i`, and
  :math:`y_{j, b}` denotes the :math:`b`-th row of :math:`x_j`.
  
  Parameters
  ----------
  transformer: pairwise transformer of BasePairwiseTransformer scitype
  aggfunc: aggregation function (2D np.array) -> float or None, optional
      default = None = np.mean
  aggfunc_is_symm: bool, optional, default=False
      whether aggregation function is symmetric (should be set according to aggfunc)
          i.e., invariant under transposing argument, it always holds that
              aggfunc(matrix) = aggfunc(np.transpose(matrix))
          used for fast computation of the resultant matrix (if symmetric)
          if unknown, False is the "safe" option that ensures correctness
  
  Examples
  --------
  Mean pairwise euclidean distance between between time series
  
  >>> from sktime.dists_kernels import AggrDist, ScipyDist
  >>> mean_euc_tsdist = AggrDist(ScipyDist())
  
  Mean pairwise Gaussian kernel between time series
  
  >>> from sklearn.gaussian_process.kernels import RBF
  >>> mean_gaussian_tskernel = AggrDist(RBF())
class_docstr_tok: ["Panel","distance","from","tabular","distance","aggregation",".","panel","distance","obtained","by","applying","aggregation","function","to","tabular","distance","matrix","example",":","AggrDist","(","ScipyDist","(",")",")","is","mean","Euclidean","distance","between","series","Formal","details","(","for","real","valued","objects",",","mixed","typed","rows","in","analogy",")",":","Let",":","math",":","`","d",":","\\mathbb","{","R","}","^k","\\times","\\mathbb","{","R","}","^","{","k","}","\\rightarrow","\\mathbb","{","R","}","`","be","the","pairwise","function","in","`","transformer","`",",","when","applied","to","`","k","`","-vectors",".","Let",":","math",":","`","f",":","\\mathbb","{","R","}","^","{","n","\\","times","m","}","`","be","the","function","`","aggfunc","`","when","applied","to","an",":","math",":","`","(","n","\\times","m",")","`","matrix",".","Let",":","math",":","`","x_1",",","\\dots",",","x_N\\in","\\mathbb","{","R","}","^","{","n","\\times","k","}","`",",",":","math",":","`","y_1",",","\\dots","y_M","\\in","\\mathbb","{","R","}","^","{","m","\\times","k","}","`","be","collections","of","matrices",",","representing","time","series","panel","valued","inputs","`","X","`","and","`","X2","`",",","as","follows",":",":","math",":","`","x_i","`","is","the","`","i","`","-th","instance","in","`","X","`",",","and",":","math",":","`","x_","{","i",",","j\\ell","}","`","is","the","`","j","`","-th","time","point",",","`","\\ell","`","-th","variable","of","`","X","`",".","Analogous","for",":","math",":","`","y","`","and","`","X2","`",".","Then",",","`","transform","(","X",",","X2",")","`","returns","the",":","math",":","`","(","N","\\times","M",")","`","matrix","with",":","math",":","`","(","i",",","j",")","`","-th","entry",":","math",":","`","f","\\left","(","(","d","(","x_","{","i",",","a","}",",","y_","{","j",",","b","}",")",")","_","{","a",",","b","}","\\right",")","`",",","where",":","math",":","`","x_","{","i",",","a","}","`","denotes","the",":","math",":","`","a","`","-th","row","of",":","math",":","`","x_i","`",",","and",":","math",":","`","y_","{","j",",","b","}","`","denotes","the",":","math",":","`","b","`","-th","row","of",":","math",":","`","x_j","`",".","Parameters","--","--","--","--","--","transformer",":","pairwise","transformer","of","BasePairwiseTransformer","scitype","aggfunc",":","aggregation","function","(","2D","np.array",")","-",">","float","or","None",",","optional","default","=","None","=","np.mean","aggfunc_is_symm",":","bool",",","optional",",","default=False","whether","aggregation","function","is","symmetric","(","should","be","set","according","to","aggfunc",")","i.e.",",","invariant","under","transposing","argument",",","it","always","holds","that","aggfunc","(","matrix",")","=","aggfunc","(","np.transpose","(","matrix",")",")","used","for","fast","computation","of","the","resultant","matrix","(","if","symmetric",")","if","unknown",",","False","is","the","``","safe","''","option","that","ensures","correctness","Examples","--","--","--","--","Mean","pairwise","euclidean","distance","between","between","time","series",">",">",">","from","sktime.dists_kernels","import","AggrDist",",","ScipyDist",">",">",">","mean_euc_tsdist","=","AggrDist","(","ScipyDist","(",")",")","Mean","pairwise","Gaussian","kernel","between","time","series",">",">",">","from","sklearn.gaussian_process.kernels","import","RBF",">",">",">","mean_gaussian_tskernel","=","AggrDist","(","RBF","(",")",")"]
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]
      """
      n = len(X)
      m = len(X2)
  
      X_equals_X2 = deep_equals(X, X2)
  
      aggfunc = self.aggfunc
      aggfunc_is_symm = self.aggfunc_is_symm
      transformer = self.transformer
      if aggfunc is None:
          aggfunc = np.mean
          aggfunc_is_symm = True
  
      if isinstance(transformer, BasePairwiseTransformer):
          transformer_symm = transformer.get_tag("symmetric", False)
      else:
          transformer_symm = False
  
      # whether we know that resulting matrix must be symmetric
      # a sufficient condition for this:
      # transformer is symmetric; X equals X2; and aggfunc is symmetric
      all_symm = aggfunc_is_symm and transformer_symm and X_equals_X2
  
      distmat = np.zeros((n, m), dtype="float")
  
      for i in range(n):
          for j in range(m):
              if all_symm and j < i:
                  distmat[i, j] = distmat[j, i]
              else:
                  distmat[i, j] = aggfunc(self.transformer(X[i], X2[j]))
  
      return distmat
  
file_path: sktime/sktime/dists_kernels/compose_tab_to_panel.py
imports: import numpy
  from sktime.dists_kernels.base import BasePairwiseTransformer, BasePairwiseTransformerPanel
  from sktime.utils._testing.deep_equals import deep_equals
label_desc: Use image node_id 2 for calling the AggrDist obj's underlying member method code with example usage: obj._transform(X, X2) and returns: distmat