(self, prep)
Update the input shape for the Keras architecture.
        We do this by running preprocessing on the training data frame to get the final number of features.
Update the input shape for the Keras architecture.
        We do this by running preprocessing on the training data frame to get the final number of features.
Update the input shape for the Keras architecture . We do this by running preprocessing on the training data frame to get the final number of features .
def _keras_update_shape(self, prep):
        """
        Update the input shape for the Keras architecture.
        We do this by running preprocessing on the training data frame to get the final number of features.
        """

        # Run preprocessing on the training data
        X_transform = prep.fit_transform(self.X_train)

        # If the input shape has not been specified, it is simply the number of features in X_transform
        if 'input_shape' not in self.model.first_layer_kwargs:
            self.model.first_layer_kwargs['input_shape'] = tuple([X_transform.shape[1]])
        # Else update the input shape based on the number of features after preprocessing
        else:
            # Transform to a list to make the input_shape mutable
            self.model.first_layer_kwargs['input_shape'] = list(self.model.first_layer_kwargs['input_shape'])
            # Update the number of features based on X_transform
            if self.model.lags:
                self.model.first_layer_kwargs['input_shape'][-1] = X_transform.shape[1]//(self.model.lags + (1 if self.model.current_sample_as_input else 0))
            else:
                self.model.first_layer_kwargs['input_shape'][-1] = X_transform.shape[1]//np.prod(self.model.first_layer_kwargs['input_shape'][:-1])
            # Transform back to a tuple as required by Keras
            self.model.first_layer_kwargs['input_shape'] = tuple(self.model.first_layer_kwargs['input_shape'])
        
        # Ensure the Architecture has been updated
        self.model.architecture.iloc[0, 2]['input_shape'] = self.model.first_layer_kwargs['input_shape']
        
        # 2D, 3D and 4D data is valid. 
        # e.g. The input_shape can be a tuple of (subsequences, timesteps, features), with subsequences and timesteps as optional.
        # A 4D shape may be valid for e.g. a ConvLSTM with (timesteps, rows, columns, features) 
        if len(self.model.first_layer_kwargs['input_shape']) > 5:
            err = "Unsupported input_shape: {}".format(self.model.first_layer_kwargs['input_shape'])
            raise Exception(err)
def _keras_update_shape ( self , prep ) : # Run preprocessing on the training data X_transform = prep . fit_transform ( self . X_train ) # If the input shape has not been specified, it is simply the number of features in X_transform if 'input_shape' not in self . model . first_layer_kwargs : self . model . first_layer_kwargs [ 'input_shape' ] = tuple ( [ X_transform . shape [ 1 ] ] ) # Else update the input shape based on the number of features after preprocessing else : # Transform to a list to make the input_shape mutable self . model . first_layer_kwargs [ 'input_shape' ] = list ( self . model . first_layer_kwargs [ 'input_shape' ] ) # Update the number of features based on X_transform if self . model . lags : self . model . first_layer_kwargs [ 'input_shape' ] [ - 1 ] = X_transform . shape [ 1 ] // ( self . model . lags + ( 1 if self . model . current_sample_as_input else 0 ) ) else : self . model . first_layer_kwargs [ 'input_shape' ] [ - 1 ] = X_transform . shape [ 1 ] // np . prod ( self . model . first_layer_kwargs [ 'input_shape' ] [ : - 1 ] ) # Transform back to a tuple as required by Keras self . model . first_layer_kwargs [ 'input_shape' ] = tuple ( self . model . first_layer_kwargs [ 'input_shape' ] ) # Ensure the Architecture has been updated self . model . architecture . iloc [ 0 , 2 ] [ 'input_shape' ] = self . model . first_layer_kwargs [ 'input_shape' ] # 2D, 3D and 4D data is valid.  # e.g. The input_shape can be a tuple of (subsequences, timesteps, features), with subsequences and timesteps as optional. # A 4D shape may be valid for e.g. a ConvLSTM with (timesteps, rows, columns, features)  if len ( self . model . first_layer_kwargs [ 'input_shape' ] ) > 5 : err = "Unsupported input_shape: {}" . format ( self . model . first_layer_kwargs [ 'input_shape' ] ) raise Exception ( err )