classification/tree_manager.py
def change_oh_cat(self, target: str, df: DataFrame, pref_order: Dict[int, int] = None):
        """
        Change the one-hot coding to a single column with numbers for the different categories.
        Optionally, a given order for the categories can be given in pref_order.
        """
        target_cols = [x for x in df.columns.values if x.split("__")[0] == target]

        if pref_order is None:
            pref_order = {x: i for i, x in enumerate(target_cols)}

        str_row = df[target_cols].idxmax(1)
        label_row = [pref_order[x] for x in str_row]
        df[target] = label_row
        df.drop(target_cols, axis=1, inplace=True)

        Change the one-hot coding to a single column with numbers for the different categories.
        Optionally, a given order for the categories can be given in pref_order.
        
Change the one-hot coding to a single column with numbers for the different categories.
Optionally, a given order for the categories can be given in pref_order.
Change the one - hot coding to a single column with numbers for the different categories . Optionally a given order for the categories can be given in pref_order .
def change_oh_cat(self, target: str, df: DataFrame, pref_order: Dict[int, int] = None):
        target_cols = [x for x in df.columns.values if x.split("__")[0] == target]
        if pref_order is None:
            pref_order = {x: i for i, x in enumerate(target_cols)}
        str_row = df[target_cols].idxmax(1)
        label_row = [pref_order[x] for x in str_row]
        df[target] = label_row
        df.drop(target_cols, axis=1, inplace=True)
def change_oh_cat ( self , target : str , df : DataFrame , pref_order : Dict [ int , int ] = None ) : target_cols = [ x for x in df . columns . values if x . split ( "__" ) [ 0 ] == target ] if pref_order is None : pref_order = { x : i for i , x in enumerate ( target_cols ) } str_row = df [ target_cols ] . idxmax ( 1 ) label_row = [ pref_order [ x ] for x in str_row ] df [ target ] = label_row df . drop ( target_cols , axis = 1 , inplace = True )
Change the one-hot coding to a single column with numbers for the different categories.
Change the one - hot coding to a single column with numbers for the different categories .
"""
        Change the one-hot coding to a single column with numbers for the different categories.
        Optionally, a given order for the categories can be given in pref_order.
        """
self
target
str
df
DataFrame
pref_order
Dict[int, int]