def fit(self, signal) -> "CostMl":
        """Set parameters of the instance.

        Args:
            signal (array): signal. Shape (n_samples,) or
                (n_samples, n_features)

        Returns:
            self
        """
        s_ = signal.reshape(-1, 1) if signal.ndim == 1 else signal

        # fit a Mahalanobis metric if self.has_custom_metric is False
        if self.has_custom_metric is False:
            covar = np.cov(s_.T)
            self.metric = inv(covar.reshape(1, 1) if covar.size == 1 else covar)

        self.gram = s_.dot(self.metric).dot(s_.T)
        self.signal = s_

        return self
Set parameters of the instance.

        Args:
            signal (array): signal. Shape (n_samples,) or
                (n_samples, n_features)

        Returns:
            self
        
src/ruptures/costs/costml.py