utils.py
def cal_categorical(target_df_1, cat_feature, cat_df):
    '''
    Calculate metrices for categorical features
        including missing values, number of classes, counts for each group, percentage for each group
    '''

    # get missing value counts
    missing_count_log = target_df_1[cat_feature].isna().sum()
    cat_df.loc[cat_feature, 'missing_count'] = missing_count_log

    # get number of classes
    num_class_log = len(target_df_1[cat_feature].value_counts().keys())
    cat_df.loc[cat_feature, 'num_class'] = num_class_log

    # get counts for each group
    class_count_log = target_df_1[cat_feature].value_counts().to_dict()
    cat_df.loc[cat_feature, 'class_count'] = [class_count_log]

    # get percentage each group covers
    class_percent_log = (target_df_1[cat_feature].value_counts() / \
    target_df_1[cat_feature].value_counts().sum()).to_dict()
    cat_df.loc[cat_feature, 'class_percent'] = [class_percent_log]

    return cat_df

    Calculate metrices for categorical features
        including missing values, number of classes, counts for each group, percentage for each group
    
Calculate metrices for categorical features
including missing values, number of classes, counts for each group, percentage for each group
Calculate metrices for categorical features including missing values number of classes counts for each group percentage for each group
def cal_categorical(target_df_1, cat_feature, cat_df):
    missing_count_log = target_df_1[cat_feature].isna().sum()
    cat_df.loc[cat_feature, 'missing_count'] = missing_count_log
    num_class_log = len(target_df_1[cat_feature].value_counts().keys())
    cat_df.loc[cat_feature, 'num_class'] = num_class_log
    class_count_log = target_df_1[cat_feature].value_counts().to_dict()
    cat_df.loc[cat_feature, 'class_count'] = [class_count_log]
    class_percent_log = (target_df_1[cat_feature].value_counts() / \
    target_df_1[cat_feature].value_counts().sum()).to_dict()
    cat_df.loc[cat_feature, 'class_percent'] = [class_percent_log]
    return cat_df
def cal_categorical ( target_df_1 , cat_feature , cat_df ) : missing_count_log = target_df_1 [ cat_feature ] . isna ( ) . sum ( ) cat_df . loc [ cat_feature , 'missing_count' ] = missing_count_log num_class_log = len ( target_df_1 [ cat_feature ] . value_counts ( ) . keys ( ) ) cat_df . loc [ cat_feature , 'num_class' ] = num_class_log class_count_log = target_df_1 [ cat_feature ] . value_counts ( ) . to_dict ( ) cat_df . loc [ cat_feature , 'class_count' ] = [ class_count_log ] class_percent_log = ( target_df_1 [ cat_feature ] . value_counts ( ) / target_df_1 [ cat_feature ] . value_counts ( ) . sum ( ) ) . to_dict ( ) cat_df . loc [ cat_feature , 'class_percent' ] = [ class_percent_log ] return cat_df
Calculate metrices for categorical features
including missing values, number of classes, counts for each group, percentage for each group
Calculate metrices for categorical features including missing values number of classes counts for each group percentage for each group
'''
    Calculate metrices for categorical features
        including missing values, number of classes, counts for each group, percentage for each group
    ''' # get missing value counts # get number of classes # get counts for each group # get percentage each group covers
target_df_1
cat_feature
cat_df