def METHOD_NAME(self, X, y):
    """Fit a pipeline on cases (X,y), where y is the target variable.
    Parameters
    ----------
    X : 3D np.array of shape = [n_instances, n_dimensions, series_length]
        The training data.
    y : array-like, shape = [n_instances]
        The class labels.
    Returns
    -------
    self :
        Reference to self.
    Notes
    -----
    Changes state by creating a fitted model that updates attributes
    ending in "_" and sets is_fitted flag to True.
    """
    self._transformer = MatrixProfile(m=self.subsequence_length)
    self._estimator = _clone_estimator(
        KNeighborsClassifier(n_neighbors=1)
        if self.estimator is None
        else self.estimator,
        self.random_state,
    )
    m = getattr(self._estimator, "n_jobs", None)
    if m is not None:
        self._estimator.n_jobs = self._threads_to_use
    X_t = self._transformer.fit_transform(X, y)
    self._estimator.fit(X_t, y)
    return self