build/lib/AutoMxL/Preprocessing/Categorical.py
def fit(self, df, l_var=None, target=None, verbose=False):
        """ Fit encoder on dataset following method

        Parameters
        ----------
        df : DataFrame
            input dataset
        l_var : list (Default None)
            names of the variables to encode.
            If None, all the categorical and boolean features
        target : string (Default None)
            name of the target for deep_encoder method
        verbose : boolean (Default False)
            Get logging information
        """
        if self.method == 'deep_encoder':
            assert target is not None, 'fill target parameter to use deep encoder'

        # get categorical and boolean features (see Features_Type module doc)
        l_cat = [col for col in df.columns.tolist() if
                 (is_categorical(df, col) or is_boolean(df, col)) and col != target]

        # list of features to encode
        if l_var is None:
            self.l_var2encode = l_cat
        else:
            self.l_var2encode = [col for col in l_var if col in l_cat]

        df_local = df.copy()

        # store target
        self.target = target

        if verbose:
            print(" **method : " + self.method)
            if (self.method == 'deep_encoder') and (len(self.l_var2encode) > 20):
                color_print('  might take a little while, make coffee', 32)
            print("  >", len(self.l_var2encode), "features to encode")
            if len(self.l_var2encode) > 0:
                print(" ", self.l_var2encode)

        if len(self.l_var2encode) > 0:
            # deep learning embedded representation method
            if self.method == 'deep_encoder':
                self.d_int_encoders, self.d_embeddings, self.d_metrics = \
                    get_embedded_cat(df_local, self.l_var2encode, target, batch_size, n_epoch, learning_rate,
                                     verbose=False)

        # Fitted !
        self.is_fitted = True

        # verbose
        if verbose:
            if (self.method == "deep_encoder") and len(self.l_var2encode) > 0:
                print("  NN Loss:", round(self.d_metrics['loss'], 4), "/ Accuracy:",
                      round(self.d_metrics['accuracy'], 4))
                print("  Epoch:", n_epoch, "/ batch:", batch_size, "/ l_rate:", learning_rate)
 Fit encoder on dataset following method

        Parameters
        ----------
        df : DataFrame
            input dataset
        l_var : list (Default None)
            names of the variables to encode.
            If None, all the categorical and boolean features
        target : string (Default None)
            name of the target for deep_encoder method
        verbose : boolean (Default False)
            Get logging information
        
Fit encoder on dataset following method
Parameters

df : DataFrame
input dataset
l_var : list (Default None)
names of the variables to encode.
If None, all the categorical and boolean features
target : string (Default None)
name of the target for deep_encoder method
verbose : boolean (Default False)
Get logging information
Fit encoder on dataset following method Parameters df : DataFrame input dataset l_var : list ( Default None ) names of the variables to encode . If None all the categorical and boolean features target : string ( Default None ) name of the target for deep_encoder method verbose : boolean ( Default False ) Get logging information
def fit(self, df, l_var=None, target=None, verbose=False):
        if self.method == 'deep_encoder':
            assert target is not None, 'fill target parameter to use deep encoder'
        l_cat = [col for col in df.columns.tolist() if
                 (is_categorical(df, col) or is_boolean(df, col)) and col != target]
        if l_var is None:
            self.l_var2encode = l_cat
        else:
            self.l_var2encode = [col for col in l_var if col in l_cat]
        df_local = df.copy()
        self.target = target
        if verbose:
            print(" **method : " + self.method)
            if (self.method == 'deep_encoder') and (len(self.l_var2encode) > 20):
                color_print('  might take a little while, make coffee', 32)
            print("  >", len(self.l_var2encode), "features to encode")
            if len(self.l_var2encode) > 0:
                print(" ", self.l_var2encode)
        if len(self.l_var2encode) > 0:
            if self.method == 'deep_encoder':
                self.d_int_encoders, self.d_embeddings, self.d_metrics = \
                    get_embedded_cat(df_local, self.l_var2encode, target, batch_size, n_epoch, learning_rate,
                                     verbose=False)
        self.is_fitted = True
        if verbose:
            if (self.method == "deep_encoder") and len(self.l_var2encode) > 0:
                print("  NN Loss:", round(self.d_metrics['loss'], 4), "/ Accuracy:",
                      round(self.d_metrics['accuracy'], 4))
                print("  Epoch:", n_epoch, "/ batch:", batch_size, "/ l_rate:", learning_rate)
def fit ( self , df , l_var = None , target = None , verbose = False ) : if self . method == 'deep_encoder' : assert target is not None , 'fill target parameter to use deep encoder' l_cat = [ col for col in df . columns . tolist ( ) if ( is_categorical ( df , col ) or is_boolean ( df , col ) ) and col != target ] if l_var is None : self . l_var2encode = l_cat else : self . l_var2encode = [ col for col in l_var if col in l_cat ] df_local = df . copy ( ) self . target = target if verbose : print ( " **method : " + self . method ) if ( self . method == 'deep_encoder' ) and ( len ( self . l_var2encode ) > 20 ) : color_print ( '  might take a little while, make coffee' , 32 ) print ( "  >" , len ( self . l_var2encode ) , "features to encode" ) if len ( self . l_var2encode ) > 0 : print ( " " , self . l_var2encode ) if len ( self . l_var2encode ) > 0 : if self . method == 'deep_encoder' : self . d_int_encoders , self . d_embeddings , self . d_metrics = get_embedded_cat ( df_local , self . l_var2encode , target , batch_size , n_epoch , learning_rate , verbose = False ) self . is_fitted = True if verbose : if ( self . method == "deep_encoder" ) and len ( self . l_var2encode ) > 0 : print ( "  NN Loss:" , round ( self . d_metrics [ 'loss' ] , 4 ) , "/ Accuracy:" , round ( self . d_metrics [ 'accuracy' ] , 4 ) ) print ( "  Epoch:" , n_epoch , "/ batch:" , batch_size , "/ l_rate:" , learning_rate )
Fit encoder on dataset following method
Parameters
Fit encoder on dataset following method Parameters
""" Fit encoder on dataset following method

        Parameters
        ----------
        df : DataFrame
            input dataset
        l_var : list (Default None)
            names of the variables to encode.
            If None, all the categorical and boolean features
        target : string (Default None)
            name of the target for deep_encoder method
        verbose : boolean (Default False)
            Get logging information
        """ # get categorical and boolean features (see Features_Type module doc) # list of features to encode # store target # deep learning embedded representation method # Fitted ! # verbose
self
df
l_var
target
verbose