(self, X, y=None)
return self.X_transform
Transform X with the encoding and scaling requirements set by fit().
        This function will perform One Hot Encoding, Feature Hashing and Scaling on X.
        Returns X_transform as a numpy array or a pandas dataframe based on return_type set in constructor.
Transform X with the encoding and scaling requirements set by fit().
        This function will perform One Hot Encoding, Feature Hashing and Scaling on X.
        Returns X_transform as a numpy array or a pandas dataframe based on return_type set in constructor.
Transform X with the encoding and scaling requirements set by fit () . This function will perform One Hot Encoding Feature Hashing and Scaling on X . Returns X_transform as a numpy array or a pandas dataframe based on return_type set in constructor .
def transform(self, X, y=None):
        """
        Transform X with the encoding and scaling requirements set by fit().
        This function will perform One Hot Encoding, Feature Hashing and Scaling on X.
        Returns X_transform as a numpy array or a pandas dataframe based on return_type set in constructor.
        """
        
        self.X_transform = None
        
        if self.ohe:
            # Get a subset of the data that requires one hot encoding
            self.ohe_df = X[self.ohe_meta.index.tolist()]

            # Apply one hot encoding to relevant columns
            self.ohe_df = pd.get_dummies(self.ohe_df, columns=self.ohe_df.columns)

            # Align the columns with the original dataset. 
            # This is to prevent different number or order of features between training and test datasets.
            self.ohe_df = self.ohe_df.align(self.ohe_df_structure, join='right', axis=1)[0]

            # Fill missing values in the OHE dataframe, that may appear after alignment, with zeros.
            self.ohe_df = self.fillna(self.ohe_df, missing="zeros")
            
            # Add the encoded columns to the result dataset
            self.X_transform = self.ohe_df
        
        if self.hash:
            # Get a subset of the data that requires feature hashing
            self.hash_df = X[self.hash_meta.index.tolist()]
            hash_cols = self.hash_df.columns

            # Hash unique values for each relevant column and then join to a dataframe for hashed data
            for c in hash_cols:
                unique = self.hasher(self.hash_df, c, self.hash_meta["hash_features"].loc[c])
                self.hash_df = self.hash_df.join(unique, on=c)
                self.hash_df = self.hash_df.drop(c, axis=1)
        
        if self.scale:
            # Get a subset of the data that requires scaling
            self.scale_df = X[self.scale_meta.index.tolist()]

        # If scale_hashed = True join the hashed columns to the scaling dataframe
        if self.hash and self.scale_hashed:
            if self.scale:
                self.scale_df = self.scale_df.join(self.hash_df)
            else:
                self.scale_df = self.hash_df
                # If only hashed columns are being scaled, the scaler needs to be instantiated
                self.scaler_instance = self.get_scaler(self.scale_df, missing=self.missing, scaler=self.scaler, **self.kwargs)
        elif self.hash:
            # Add the hashed columns to the result dataset
            if self.X_transform is None:
                self.X_transform = self.hash_df
            else:
                self.X_transform = self.X_transform.join(self.hash_df)
        
        # Perform scaling on the relevant data
        if len(self.scale_df) > 0:
            self.scale_df = self.fillna(self.scale_df, missing=self.missing)
            self.scale_df = pd.DataFrame(self.scaler_instance.transform(self.scale_df), index=self.scale_df.index, columns=self.scale_df.columns)
            
            # Add the scaled columns to the result dataset
            if self.X_transform is None:
                self.X_transform = self.scale_df
            else:
                self.X_transform = self.X_transform.join(self.scale_df)
               
        if self.no_prep:
            # Get a subset of the data that doesn't require preprocessing
            self.no_prep_df = X[self.none_meta.index.tolist()]
        
            # Finally join the columns that do not require preprocessing to the result dataset
            if self.X_transform is None:
                self.X_transform = self.no_prep_df
            else:
                self.X_transform = self.X_transform.join(self.no_prep_df)
        
        if self.return_type == 'np':
            return self.X_transform.values
        
        return self.X_transform
def transform ( self , X , y = None ) : self . X_transform = None if self . ohe : # Get a subset of the data that requires one hot encoding self . ohe_df = X [ self . ohe_meta . index . tolist ( ) ] # Apply one hot encoding to relevant columns self . ohe_df = pd . get_dummies ( self . ohe_df , columns = self . ohe_df . columns ) # Align the columns with the original dataset.  # This is to prevent different number or order of features between training and test datasets. self . ohe_df = self . ohe_df . align ( self . ohe_df_structure , join = 'right' , axis = 1 ) [ 0 ] # Fill missing values in the OHE dataframe, that may appear after alignment, with zeros. self . ohe_df = self . fillna ( self . ohe_df , missing = "zeros" ) # Add the encoded columns to the result dataset self . X_transform = self . ohe_df if self . hash : # Get a subset of the data that requires feature hashing self . hash_df = X [ self . hash_meta . index . tolist ( ) ] hash_cols = self . hash_df . columns # Hash unique values for each relevant column and then join to a dataframe for hashed data for c in hash_cols : unique = self . hasher ( self . hash_df , c , self . hash_meta [ "hash_features" ] . loc [ c ] ) self . hash_df = self . hash_df . join ( unique , on = c ) self . hash_df = self . hash_df . drop ( c , axis = 1 ) if self . scale : # Get a subset of the data that requires scaling self . scale_df = X [ self . scale_meta . index . tolist ( ) ] # If scale_hashed = True join the hashed columns to the scaling dataframe if self . hash and self . scale_hashed : if self . scale : self . scale_df = self . scale_df . join ( self . hash_df ) else : self . scale_df = self . hash_df # If only hashed columns are being scaled, the scaler needs to be instantiated self . scaler_instance = self . get_scaler ( self . scale_df , missing = self . missing , scaler = self . scaler , * * self . kwargs ) elif self . hash : # Add the hashed columns to the result dataset if self . X_transform is None : self . X_transform = self . hash_df else : self . X_transform = self . X_transform . join ( self . hash_df ) # Perform scaling on the relevant data if len ( self . scale_df ) > 0 : self . scale_df = self . fillna ( self . scale_df , missing = self . missing ) self . scale_df = pd . DataFrame ( self . scaler_instance . transform ( self . scale_df ) , index = self . scale_df . index , columns = self . scale_df . columns ) # Add the scaled columns to the result dataset if self . X_transform is None : self . X_transform = self . scale_df else : self . X_transform = self . X_transform . join ( self . scale_df ) if self . no_prep : # Get a subset of the data that doesn't require preprocessing self . no_prep_df = X [ self . none_meta . index . tolist ( ) ] # Finally join the columns that do not require preprocessing to the result dataset if self . X_transform is None : self . X_transform = self . no_prep_df else : self . X_transform = self . X_transform . join ( self . no_prep_df ) if self . return_type == 'np' : return self . X_transform . values return self . X_transform