sklearn_utils/utils/data_utils.py
def feature_importance_report(X,
                              y,
                              threshold=0.001,
                              correcting_multiple_hypotesis=True,
                              method='fdr_bh',
                              alpha=0.1,
                              sort_by='pval'):
    '''
    Provide signifance for features in dataset with anova using multiple hypostesis testing

    :param X: List of dict with key as feature names and values as features
    :param y: Labels
    :param threshold: Low-variens threshold to eliminate low varience features
    :param correcting_multiple_hypotesis: corrects p-val with multiple hypotesis testing
    :param method: method of multiple hypotesis testing
    :param alpha: alpha of multiple hypotesis testing
    :param sort_by: sorts output dataframe by pval or F
    :return: DataFrame with F and pval for each feature with their average values 
    '''
    df = variance_threshold_on_df(
        pd.DataFrame.from_records(X), threshold=threshold)

    F, pvals = f_classif(df.values, y)

    if correcting_multiple_hypotesis:
        _, pvals, _, _ = multipletests(pvals, alpha=alpha, method=method)

    df['labels'] = y
    df_mean = df.groupby('labels').mean().T

    df_mean['F'] = F
    df_mean['pval'] = pvals

    return df_mean.sort_values(sort_by, ascending=True)
def feature_importance_report(X,
                              y,
                              threshold=0.001,
                              correcting_multiple_hypotesis=True,
                              method='fdr_bh',
                              alpha=0.1,
                              sort_by='pval'):
    '''
    Provide signifance for features in dataset with anova using multiple hypostesis testing

    :param X: List of dict with key as feature names and values as features
    :param y: Labels
    :param threshold: Low-variens threshold to eliminate low varience features
    :param correcting_multiple_hypotesis: corrects p-val with multiple hypotesis testing
    :param method: method of multiple hypotesis testing
    :param alpha: alpha of multiple hypotesis testing
    :param sort_by: sorts output dataframe by pval or F
    :return: DataFrame with F and pval for each feature with their average values 
    '''
    df = variance_threshold_on_df(
        pd.DataFrame.from_records(X), threshold=threshold)

    F, pvals = f_classif(df.values, y)

    if correcting_multiple_hypotesis:
        _, pvals, _, _ = multipletests(pvals, alpha=alpha, method=method)

    df['labels'] = y
    df_mean = df.groupby('labels').mean().T

    df_mean['F'] = F
    df_mean['pval'] = pvals

    return df_mean.sort_values(sort_by, ascending=True)
def feature_importance_report ( X , y , threshold = 0.001 , correcting_multiple_hypotesis = True , method = 'fdr_bh' , alpha = 0.1 , sort_by = 'pval' ) : df = variance_threshold_on_df ( pd . DataFrame . from_records ( X ) , threshold = threshold ) F , pvals = f_classif ( df . values , y ) if correcting_multiple_hypotesis : _ , pvals , _ , _ = multipletests ( pvals , alpha = alpha , method = method ) df [ 'labels' ] = y df_mean = df . groupby ( 'labels' ) . mean ( ) . T df_mean [ 'F' ] = F df_mean [ 'pval' ] = pvals return df_mean . sort_values ( sort_by , ascending = True )
Provide signifance for features in dataset with anova using multiple hypostesis testing

    :param X: List of dict with key as feature names and values as features
    :param y: Labels
    :param threshold: Low-variens threshold to eliminate low varience features
    :param correcting_multiple_hypotesis: corrects p-val with multiple hypotesis testing
    :param method: method of multiple hypotesis testing
    :param alpha: alpha of multiple hypotesis testing
    :param sort_by: sorts output dataframe by pval or F
    :return: DataFrame with F and pval for each feature with their average values
Provide signifance for features in dataset with anova using multiple hypostesis testing