fair_dag.py
def home():
    """
    Main Function Flask function

    html adopts hierachical format. child html file takes care of DAG visualization while parent html deals with dynamic changes in codes, dag color, tables and histograms.
    In Main home page:
        Display user information in head row
        Display raw pipeline code. Change color w.r.t click events
        Display DAG generated from pipeline code. Change color w.r.t click events
        Display intermediate changes in both static lables and population stats
        Display visualization of changes in static lables and performance labels
    Returns:
        url for main home page.
    """

    selected_status = request.args.get('type')
    if selected_status is not None:
        cache.append(selected_status)

    corr_color = [rand_rgb[int(step)] for step in cache]
    plots = {}
    to_plot = []
    code_with_color = ""

    # variable initilization
    tables_to_display, titles, labels, code_titles, plt_xs, plt_ys, plt_titles, plt_xas, plt_yas, plot_log_changes = [], [], [], [], [], [], [], [], [], []

    # cache is used to store user click events
    for status in cache:
        if 'Classifier' in int_to_string(int(status)):
            label_inverse = {1: '<=50K', 0:'>50K'}
            target_df[target_name].replace(label_inverse, inplace = True)
            target_df['pred_'+target_name].replace(label_inverse, inplace = True)
            plt_titles.insert(0, 'Performance Label')
            to_plot.insert(0, (get_performance_label(target_df, cat_target, target_name, pos_group), perform_target))
            to_plot.append(static_label(target_df, cat_target, target_name))
            plot_log_changes.append(pd.DataFrame(static_label(target_df, cat_target, target_name)))
        else:
            to_plot.append(sort_dict_key(plot_dict[int(status)]))
            plot_log_changes.append(pd.DataFrame(sort_dict_key(plot_dict[int(status)])))

        # display tables
        if int(status) in log_dict.keys():
            temp_table = log_dict[int(status)]

            if len(plot_log_changes) == 1:
                tables_to_display.append('No changes')
            else:
                if plot_log_changes[-1].equals(plot_log_changes[-2]):
                    tables_to_display.append('No changes')
                else:
                    tables_to_display.append((plot_log_changes[-1] - plot_log_changes[-2]).to_html(classes = 'table table-striped'))

            for key, dataframe in temp_table.items():

                tables_to_display.append(dataframe.to_html(classes = 'table table-striped'))
                num_cat = "NUMERICAL features" if key == 'num' else "CATEGORICAL features"
                titles.append(int_to_string(int(status)))
                labels.append(' -- Static Label, show changes in percentage')
                titles.append(int_to_string(int(status)))
                labels.append(" -- TARGET changed in "+num_cat)
                code_titles.append(int_to_string(int(status)))

                # start_plotly
                if key == 'cat':
                    plt_titles.append('INSPECTING ' + int_to_string(int(status)))
                else:
                    plt_titles.append('INSPECTING ' + int_to_string(int(status)))
        else:

            if len(plot_log_changes) == 1:
                tables_to_display.append('No changes')
            else:
                if plot_log_changes[-1].equals(plot_log_changes[-2]):
                    tables_to_display.append('No changes')
                else:
                    tables_to_display.append((plot_log_changes[-1] - plot_log_changes[-2]).to_html(classes = 'table table-striped'))
            tables_to_display.append('No changes')
            titles.append(int_to_string(int(status)))
            labels.append(' -- Static Label, show changes in percentage')
            titles.append(int_to_string(int(status)))
            labels.append('')
            code_titles.append(int_to_string(int(status)))

            plt_titles.append('INSPECTING ' + int_to_string(int(status)))

        plots = create_hist_sub_plot(to_plot[::-1], plt_titles[::-1], pos_group)

    # change code color w.r.t click events
    code_with_color = change_code_color(corr_color, code_titles, code)
    template_to_render = user_id if demo=="USER" else demo

    # parse variables to html file.
    return render_template(f'{template_to_render}.html', 
        plots = plots, tables = tables_to_display[::-1], titles = titles[::-1], 
        labels = labels[::-1], colors = np.array(corr_color[::-1]).repeat(2).tolist(), 
        code = code_with_color, name = name, org = organization, script_name = script_name)

    Main Function Flask function

    html adopts hierachical format. child html file takes care of DAG visualization while parent html deals with dynamic changes in codes, dag color, tables and histograms.
    In Main home page:
        Display user information in head row
        Display raw pipeline code. Change color w.r.t click events
        Display DAG generated from pipeline code. Change color w.r.t click events
        Display intermediate changes in both static lables and population stats
        Display visualization of changes in static lables and performance labels
    Returns:
        url for main home page.
    
Main Function Flask function
html adopts hierachical format. child html file takes care of DAG visualization while parent html deals with dynamic changes in codes, dag color, tables and histograms.
In Main home page:
Display user information in head row
Display raw pipeline code. Change color w.r.t click events
Display DAG generated from pipeline code. Change color w.r.t click events
Display intermediate changes in both static lables and population stats
Display visualization of changes in static lables and performance labels
Main Function Flask function html adopts hierachical format . child html file takes care of DAG visualization while parent html deals with dynamic changes in codes dag color tables and histograms . In Main home page : Display user information in head row Display raw pipeline code . Change color w . r . t click events Display DAG generated from pipeline code . Change color w . r . t click events Display intermediate changes in both static lables and population stats Display visualization of changes in static lables and performance labels
def home():
    selected_status = request.args.get('type')
    if selected_status is not None:
        cache.append(selected_status)
    corr_color = [rand_rgb[int(step)] for step in cache]
    plots = {}
    to_plot = []
    code_with_color = ""
    tables_to_display, titles, labels, code_titles, plt_xs, plt_ys, plt_titles, plt_xas, plt_yas, plot_log_changes = [], [], [], [], [], [], [], [], [], []
    for status in cache:
        if 'Classifier' in int_to_string(int(status)):
            label_inverse = {1: '<=50K', 0:'>50K'}
            target_df[target_name].replace(label_inverse, inplace = True)
            target_df['pred_'+target_name].replace(label_inverse, inplace = True)
            plt_titles.insert(0, 'Performance Label')
            to_plot.insert(0, (get_performance_label(target_df, cat_target, target_name, pos_group), perform_target))
            to_plot.append(static_label(target_df, cat_target, target_name))
            plot_log_changes.append(pd.DataFrame(static_label(target_df, cat_target, target_name)))
        else:
            to_plot.append(sort_dict_key(plot_dict[int(status)]))
            plot_log_changes.append(pd.DataFrame(sort_dict_key(plot_dict[int(status)])))
        if int(status) in log_dict.keys():
            temp_table = log_dict[int(status)]
            if len(plot_log_changes) == 1:
                tables_to_display.append('No changes')
            else:
                if plot_log_changes[-1].equals(plot_log_changes[-2]):
                    tables_to_display.append('No changes')
                else:
                    tables_to_display.append((plot_log_changes[-1] - plot_log_changes[-2]).to_html(classes = 'table table-striped'))
            for key, dataframe in temp_table.items():
                tables_to_display.append(dataframe.to_html(classes = 'table table-striped'))
                num_cat = "NUMERICAL features" if key == 'num' else "CATEGORICAL features"
                titles.append(int_to_string(int(status)))
                labels.append(' -- Static Label, show changes in percentage')
                titles.append(int_to_string(int(status)))
                labels.append(" -- TARGET changed in "+num_cat)
                code_titles.append(int_to_string(int(status)))
                if key == 'cat':
                    plt_titles.append('INSPECTING ' + int_to_string(int(status)))
                else:
                    plt_titles.append('INSPECTING ' + int_to_string(int(status)))
        else:
            if len(plot_log_changes) == 1:
                tables_to_display.append('No changes')
            else:
                if plot_log_changes[-1].equals(plot_log_changes[-2]):
                    tables_to_display.append('No changes')
                else:
                    tables_to_display.append((plot_log_changes[-1] - plot_log_changes[-2]).to_html(classes = 'table table-striped'))
            tables_to_display.append('No changes')
            titles.append(int_to_string(int(status)))
            labels.append(' -- Static Label, show changes in percentage')
            titles.append(int_to_string(int(status)))
            labels.append('')
            code_titles.append(int_to_string(int(status)))
            plt_titles.append('INSPECTING ' + int_to_string(int(status)))
        plots = create_hist_sub_plot(to_plot[::-1], plt_titles[::-1], pos_group)
    code_with_color = change_code_color(corr_color, code_titles, code)
    template_to_render = user_id if demo=="USER" else demo
    return render_template(f'{template_to_render}.html', 
        plots = plots, tables = tables_to_display[::-1], titles = titles[::-1], 
        labels = labels[::-1], colors = np.array(corr_color[::-1]).repeat(2).tolist(), 
        code = code_with_color, name = name, org = organization, script_name = script_name)
def home ( ) : selected_status = request . args . get ( 'type' ) if selected_status is not None : cache . append ( selected_status ) corr_color = [ rand_rgb [ int ( step ) ] for step in cache ] plots = { } to_plot = [ ] code_with_color = "" tables_to_display , titles , labels , code_titles , plt_xs , plt_ys , plt_titles , plt_xas , plt_yas , plot_log_changes = [ ] , [ ] , [ ] , [ ] , [ ] , [ ] , [ ] , [ ] , [ ] , [ ] for status in cache : if 'Classifier' in int_to_string ( int ( status ) ) : label_inverse = { 1 : '<=50K' , 0 : '>50K' } target_df [ target_name ] . replace ( label_inverse , inplace = True ) target_df [ 'pred_' + target_name ] . replace ( label_inverse , inplace = True ) plt_titles . insert ( 0 , 'Performance Label' ) to_plot . insert ( 0 , ( get_performance_label ( target_df , cat_target , target_name , pos_group ) , perform_target ) ) to_plot . append ( static_label ( target_df , cat_target , target_name ) ) plot_log_changes . append ( pd . DataFrame ( static_label ( target_df , cat_target , target_name ) ) ) else : to_plot . append ( sort_dict_key ( plot_dict [ int ( status ) ] ) ) plot_log_changes . append ( pd . DataFrame ( sort_dict_key ( plot_dict [ int ( status ) ] ) ) ) if int ( status ) in log_dict . keys ( ) : temp_table = log_dict [ int ( status ) ] if len ( plot_log_changes ) == 1 : tables_to_display . append ( 'No changes' ) else : if plot_log_changes [ - 1 ] . equals ( plot_log_changes [ - 2 ] ) : tables_to_display . append ( 'No changes' ) else : tables_to_display . append ( ( plot_log_changes [ - 1 ] - plot_log_changes [ - 2 ] ) . to_html ( classes = 'table table-striped' ) ) for key , dataframe in temp_table . items ( ) : tables_to_display . append ( dataframe . to_html ( classes = 'table table-striped' ) ) num_cat = "NUMERICAL features" if key == 'num' else "CATEGORICAL features" titles . append ( int_to_string ( int ( status ) ) ) labels . append ( ' -- Static Label, show changes in percentage' ) titles . append ( int_to_string ( int ( status ) ) ) labels . append ( " -- TARGET changed in " + num_cat ) code_titles . append ( int_to_string ( int ( status ) ) ) if key == 'cat' : plt_titles . append ( 'INSPECTING ' + int_to_string ( int ( status ) ) ) else : plt_titles . append ( 'INSPECTING ' + int_to_string ( int ( status ) ) ) else : if len ( plot_log_changes ) == 1 : tables_to_display . append ( 'No changes' ) else : if plot_log_changes [ - 1 ] . equals ( plot_log_changes [ - 2 ] ) : tables_to_display . append ( 'No changes' ) else : tables_to_display . append ( ( plot_log_changes [ - 1 ] - plot_log_changes [ - 2 ] ) . to_html ( classes = 'table table-striped' ) ) tables_to_display . append ( 'No changes' ) titles . append ( int_to_string ( int ( status ) ) ) labels . append ( ' -- Static Label, show changes in percentage' ) titles . append ( int_to_string ( int ( status ) ) ) labels . append ( '' ) code_titles . append ( int_to_string ( int ( status ) ) ) plt_titles . append ( 'INSPECTING ' + int_to_string ( int ( status ) ) ) plots = create_hist_sub_plot ( to_plot [ : : - 1 ] , plt_titles [ : : - 1 ] , pos_group ) code_with_color = change_code_color ( corr_color , code_titles , code ) template_to_render = user_id if demo == "USER" else demo return render_template ( f'{template_to_render}.html' , plots = plots , tables = tables_to_display [ : : - 1 ] , titles = titles [ : : - 1 ] , labels = labels [ : : - 1 ] , colors = np . array ( corr_color [ : : - 1 ] ) . repeat ( 2 ) . tolist ( ) , code = code_with_color , name = name , org = organization , script_name = script_name )
Main Function Flask function
html adopts hierachical format.
Main Function Flask function html adopts hierachical format .
"""
    Main Function Flask function

    html adopts hierachical format. child html file takes care of DAG visualization while parent html deals with dynamic changes in codes, dag color, tables and histograms.
    In Main home page:
        Display user information in head row
        Display raw pipeline code. Change color w.r.t click events
        Display DAG generated from pipeline code. Change color w.r.t click events
        Display intermediate changes in both static lables and population stats
        Display visualization of changes in static lables and performance labels
    Returns:
        url for main home page.
    """ # variable initilization # cache is used to store user click events # display tables # start_plotly # change code color w.r.t click events # parse variables to html file.
url for main home page.
url for main home page .