(self, features, return_type='np', scale_hashed=True, scale_vectors=True, missing="zeros", scaler="StandardScaler", logfile=None, **kwargs)
Initialize the Preprocessor object based on the features dataframe.
        
        **kwargs are keyword arguments passed to the sklearn scaler instance.

        The features dataframe must include these columns: name, variable_type, feature_strategy.      
        If Feature_Strategy includes hashing or text vectorizing, the strategy_args column must also be included.
        The dataframe must be indexed by name.
                
        For further information on the columns refer to the project documentation: 
        https://github.com/nabeel-oz/qlik-py-tools
Initialize the Preprocessor object based on the features dataframe.
        
        **kwargs are keyword arguments passed to the sklearn scaler instance.
Initialize the Preprocessor object based on the features dataframe . ** kwargs are keyword arguments passed to the sklearn scaler instance .
def __init__(self, features, return_type='np', scale_hashed=True, scale_vectors=True, missing="zeros", scaler="StandardScaler", logfile=None, **kwargs):
        """
        Initialize the Preprocessor object based on the features dataframe.
        
        **kwargs are keyword arguments passed to the sklearn scaler instance.

        The features dataframe must include these columns: name, variable_type, feature_strategy.      
        If Feature_Strategy includes hashing or text vectorizing, the strategy_args column must also be included.
        The dataframe must be indexed by name.
                
        For further information on the columns refer to the project documentation: 
        https://github.com/nabeel-oz/qlik-py-tools
        """
        
        self.features = features
        self.return_type = return_type
        self.scale_hashed = scale_hashed
        self.scale_vectors = scale_vectors
        self.missing = missing
        self.scaler = scaler
        self.kwargs = kwargs
        self.ohe = False
        self.hash = False
        self.cv = False
        self.tfidf = False
        self.text = False
        self.scale = False
        self.no_prep = False
        self.log = logfile
        
        # Collect features for one hot encoding
        self.ohe_meta = features.loc[features["feature_strategy"] == "one hot encoding"].copy()
        
        # Set a flag if one hot encoding will be required
        if len(self.ohe_meta) > 0:
            self.ohe = True
        
        # Collect features for hashing
        self.hash_meta = features.loc[features["feature_strategy"] == "hashing"].copy()
        
        # Set a flag if feature hashing will be required
        if len(self.hash_meta) > 0:
            self.hash = True
            
            # Convert strategy_args column to integers
            self.hash_meta.loc[:,"strategy_args"] = self.hash_meta.loc[:,"strategy_args"].astype(np.int64, errors="ignore")
        
        # Collect features for count vectorizing
        self.cv_meta = features.loc[features["feature_strategy"] == "count_vectorizing"].copy()
        
        # Set a flag if count vectorizing will be required
        if len(self.cv_meta) > 0:
            self.cv = True
            
            # Convert strategy_args column to key word arguments for the sklearn CountVectorizer class
            self.cv_meta.loc[:,"strategy_args"] = self.cv_meta.loc[:,"strategy_args"].apply(utils.get_kwargs).\
            apply(utils.get_kwargs_by_type)
        
        # Collect features for term frequency inverse document frequency (TF-IDF) vectorizing
        self.tfidf_meta = features.loc[features["feature_strategy"] == "tf_idf"].copy()
        
        # Set a flag if tfidf vectorizing will be required
        if len(self.tfidf_meta) > 0:
            self.tfidf = True
            
            # Convert strategy_args column to key word arguments for the sklearn TfidfVectorizer class
            self.tfidf_meta.loc[:,"strategy_args"] = self.tfidf_meta.loc[:,"strategy_args"].apply(utils.get_kwargs).\
            apply(utils.get_kwargs_by_type)
        
         # Collect features for text similarity one hot encoding
        self.text_meta = features.loc[features["feature_strategy"] == "text_similarity"].copy()
        
        # Set a flag if text similarity OHE will be required
        if len(self.text_meta) > 0:
            self.text = True
        
        # Collect features for scaling
        self.scale_meta = features.loc[features["feature_strategy"] == "scaling"].copy()
        
        # Set a flag if scaling will be required
        if len(self.scale_meta) > 0:
            self.scale = True
        
        # Collect other features
        self.none_meta = features.loc[features["feature_strategy"] == "none"].copy()
        
        # Set a flag if there are features that don't require preprocessing
        if len(self.none_meta) > 0:
            self.no_prep = True

        # Output information to the terminal and log file if required
        if self.log is not None:
            self._print_log(1)
def __init__ ( self , features , return_type = 'np' , scale_hashed = True , scale_vectors = True , missing = "zeros" , scaler = "StandardScaler" , logfile = None , * * kwargs ) : self . features = features self . return_type = return_type self . scale_hashed = scale_hashed self . scale_vectors = scale_vectors self . missing = missing self . scaler = scaler self . kwargs = kwargs self . ohe = False self . hash = False self . cv = False self . tfidf = False self . text = False self . scale = False self . no_prep = False self . log = logfile # Collect features for one hot encoding self . ohe_meta = features . loc [ features [ "feature_strategy" ] == "one hot encoding" ] . copy ( ) # Set a flag if one hot encoding will be required if len ( self . ohe_meta ) > 0 : self . ohe = True # Collect features for hashing self . hash_meta = features . loc [ features [ "feature_strategy" ] == "hashing" ] . copy ( ) # Set a flag if feature hashing will be required if len ( self . hash_meta ) > 0 : self . hash = True # Convert strategy_args column to integers self . hash_meta . loc [ : , "strategy_args" ] = self . hash_meta . loc [ : , "strategy_args" ] . astype ( np . int64 , errors = "ignore" ) # Collect features for count vectorizing self . cv_meta = features . loc [ features [ "feature_strategy" ] == "count_vectorizing" ] . copy ( ) # Set a flag if count vectorizing will be required if len ( self . cv_meta ) > 0 : self . cv = True # Convert strategy_args column to key word arguments for the sklearn CountVectorizer class self . cv_meta . loc [ : , "strategy_args" ] = self . cv_meta . loc [ : , "strategy_args" ] . apply ( utils . get_kwargs ) . apply ( utils . get_kwargs_by_type ) # Collect features for term frequency inverse document frequency (TF-IDF) vectorizing self . tfidf_meta = features . loc [ features [ "feature_strategy" ] == "tf_idf" ] . copy ( ) # Set a flag if tfidf vectorizing will be required if len ( self . tfidf_meta ) > 0 : self . tfidf = True # Convert strategy_args column to key word arguments for the sklearn TfidfVectorizer class self . tfidf_meta . loc [ : , "strategy_args" ] = self . tfidf_meta . loc [ : , "strategy_args" ] . apply ( utils . get_kwargs ) . apply ( utils . get_kwargs_by_type ) # Collect features for text similarity one hot encoding self . text_meta = features . loc [ features [ "feature_strategy" ] == "text_similarity" ] . copy ( ) # Set a flag if text similarity OHE will be required if len ( self . text_meta ) > 0 : self . text = True # Collect features for scaling self . scale_meta = features . loc [ features [ "feature_strategy" ] == "scaling" ] . copy ( ) # Set a flag if scaling will be required if len ( self . scale_meta ) > 0 : self . scale = True # Collect other features self . none_meta = features . loc [ features [ "feature_strategy" ] == "none" ] . copy ( ) # Set a flag if there are features that don't require preprocessing if len ( self . none_meta ) > 0 : self . no_prep = True # Output information to the terminal and log file if required if self . log is not None : self . _print_log ( 1 )