(self, y)
return self
Make the data stationary if required.
        Fit the scaler to target values from the training set.
Make the data stationary if required.
        Fit the scaler to target values from the training set.
Make the data stationary if required . Fit the scaler to target values from the training set .
def fit(self, y):
        """
        Make the data stationary if required.
        Fit the scaler to target values from the training set.
        """

        # Apply a logarithm to make the array stationary
        if self.make_stationary == 'log':
            y = np.log(y)

        # Apply stationarity lags by differencing the array
        elif self.make_stationary == 'difference':
            y_diff = y.copy()
            len_y = len(y_diff)

            for i in range(max(self.lags), len_y):
                for lag in self.lags:
                    if isinstance(y_diff, (pd.Series, pd.DataFrame)):
                        y_diff.iloc[i] = y_diff.iloc[i] - y.iloc[i - lag]
                    else:
                        y_diff[i] = y_diff[i] - y[i - lag]
            
            # Remove targets with insufficient lag periods
            if isinstance(y_diff, (pd.Series, pd.DataFrame)):
                y = y_diff.iloc[max(self.lags):]
            else:
                y = y_diff[max(self.lags):]

        # Fit the scaler
        if self.scale:
            # Get an instance of the sklearn scaler fit to y
            self.scaler_instance = utils.get_scaler(y, missing=self.missing, scaler=self.scaler, **self.kwargs)
        
        return self
def fit ( self , y ) : # Apply a logarithm to make the array stationary if self . make_stationary == 'log' : y = np . log ( y ) # Apply stationarity lags by differencing the array elif self . make_stationary == 'difference' : y_diff = y . copy ( ) len_y = len ( y_diff ) for i in range ( max ( self . lags ) , len_y ) : for lag in self . lags : if isinstance ( y_diff , ( pd . Series , pd . DataFrame ) ) : y_diff . iloc [ i ] = y_diff . iloc [ i ] - y . iloc [ i - lag ] else : y_diff [ i ] = y_diff [ i ] - y [ i - lag ] # Remove targets with insufficient lag periods if isinstance ( y_diff , ( pd . Series , pd . DataFrame ) ) : y = y_diff . iloc [ max ( self . lags ) : ] else : y = y_diff [ max ( self . lags ) : ] # Fit the scaler if self . scale : # Get an instance of the sklearn scaler fit to y self . scaler_instance = utils . get_scaler ( y , missing = self . missing , scaler = self . scaler , * * self . kwargs ) return self