(self, X, y=None, extrapolate=1, update_features_df=False)
return X
Add lag observations to X.
        If y is available and self.model.lag_target is True, the previous target will become an additional feature in X.
        Feature definitions for the model will be updated accordingly.
Add lag observations to X.
        If y is available and self.model.lag_target is True, the previous target will become an additional feature in X.
        Feature definitions for the model will be updated accordingly.
Add lag observations to X . If y is available and self . model . lag_target is True the previous target will become an additional feature in X . Feature definitions for the model will be updated accordingly .
def _add_lags(self, X, y=None, extrapolate=1, update_features_df=False):
        """
        Add lag observations to X.
        If y is available and self.model.lag_target is True, the previous target will become an additional feature in X.
        Feature definitions for the model will be updated accordingly.
        """

        # Add lag target to the features if required
        # This will create an additional feature for each sample i.e. the previous value of y 
        if y is not None and self.model.lag_target:
            X["previous_y"] = y.shift(1)
            
            if update_features_df:
                # Check the target's data type
                dt = 'float' if is_numeric_dtype(y.iloc[:,0]) else 'str'
                # Set the preprocessing feature strategy for the lag targets
                if self.model.estimator_type == 'classifier':
                    fs = 'one hot encoding' 
                elif self.model.scale_lag_target and not self.model.scale_target:
                    fs = 'scaling'
                else:
                    fs = 'none'
                self.model.scale_lag_target
                # Update feature definitions for the model
                self.model.features_df.loc['previous_y'] = [self.model.name, 'previous_y', 'feature', dt, fs, '']

        if self.model.lags:
            # Add the lag observations
            X = utils.add_lags(X, lag=self.model.lags, extrapolate=extrapolate, dropna=True, suffix="t")
            
            if update_features_df:
                # Duplicate the feature definitions by the number of lags
                self.model.features_df = pd.concat([self.model.features_df] * (self.model.lags+extrapolate))
                # Set the new feature names as the index of the feature definitions data frame
                self.model.features_df['name'] = X.columns
                self.model.features_df = self.model.features_df.set_index('name', drop=True)

        if self.model.debug:
            self._print_log(11, data=X)

        return X
def _add_lags ( self , X , y = None , extrapolate = 1 , update_features_df = False ) : # Add lag target to the features if required # This will create an additional feature for each sample i.e. the previous value of y  if y is not None and self . model . lag_target : X [ "previous_y" ] = y . shift ( 1 ) if update_features_df : # Check the target's data type dt = 'float' if is_numeric_dtype ( y . iloc [ : , 0 ] ) else 'str' # Set the preprocessing feature strategy for the lag targets if self . model . estimator_type == 'classifier' : fs = 'one hot encoding' elif self . model . scale_lag_target and not self . model . scale_target : fs = 'scaling' else : fs = 'none' self . model . scale_lag_target # Update feature definitions for the model self . model . features_df . loc [ 'previous_y' ] = [ self . model . name , 'previous_y' , 'feature' , dt , fs , '' ] if self . model . lags : # Add the lag observations X = utils . add_lags ( X , lag = self . model . lags , extrapolate = extrapolate , dropna = True , suffix = "t" ) if update_features_df : # Duplicate the feature definitions by the number of lags self . model . features_df = pd . concat ( [ self . model . features_df ] * ( self . model . lags + extrapolate ) ) # Set the new feature names as the index of the feature definitions data frame self . model . features_df [ 'name' ] = X . columns self . model . features_df = self . model . features_df . set_index ( 'name' , drop = True ) if self . model . debug : self . _print_log ( 11 , data = X ) return X