def transform(self, X):
X = as_features(X, stack=True, bare=True)<EOL>Y = self.features_<EOL>if X.dim != Y.dim:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>.format(X.dim, Y.dim))<EOL><DEDENT>pointwise = pairwise_kernels(X.stacked_features, Y.stacked_features,<EOL>metric=self.kernel,<EOL>filter_params=True,<EOL>**self._get_kernel_params())<EOL>K = np.empty((len(X), len(Y)))<EOL>for i in range(len(X)):<EOL><INDENT>for j in range(len(Y)):<EOL><INDENT>K[i, j] = pointwise[X._boundaries[i]:X._boundaries[i+<NUM_LIT:1>],<EOL>Y._boundaries[j]:Y._boundaries[j+<NUM_LIT:1>]].mean()<EOL><DEDENT><DEDENT>return K<EOL>
Compute kernels from X to :attr:`features_`.

Parameters
----------
X : list of arrays or :class:`skl_groups.features.Features`
    The bags to compute "from". Must have same dimension as
    :attr:`features_`.

Returns
-------
K : array of shape ``[len(X), len(features_)]``
    The kernel evaluations from X to :attr:`features_`.