fairness_instru.py
def tracer(cat_col, numerical_col, sensi_atts, target_name, training = True, save_path = '', dag_save = 'pdf'):
    """
    combines describe_ver(generate intermediate dict) and visualize(DAG generation).

    args:
        cat_col: catagorical attributes used for tracing changes. String.
        numerical_col: numerical attributes used for tracing changes. String.
        sensi_atts: sensible attributes used to generate static labels. String.
        target_name: target attributes. String.
        training: Indicator for training session. False to be testing. Used for classifier train/val. Bool.
        save_path: save_path specified to save intermediate dict files. String.
        dag_save: format of DAG to be saved. String.

    return:
        function wrapper. all outputs saved to save_path using pickle.

    """
    def wrapper(func):
        def call(*args, **kwargs):
            if not os.path.exists('experiments'):
                os.mkdir('experiments')
            if not os.path.exists(save_path):
                os.mkdir(save_path)
            if not os.path.exists(save_path+'/checkpoints'):
                os.mkdir(save_path+'/checkpoints')
            if not os.path.exists(save_path+'/checkpoints/csv'):
                os.mkdir(save_path+'/checkpoints/csv')
            if training and not os.path.exists(save_path+'/checkpoints/csv/training'):
                os.mkdir(save_path+'/checkpoints/csv/training')
            if not training and not os.path.exists(save_path+'/checkpoints/csv/testing'):
                os.mkdir(save_path+'/checkpoints/csv/testing')

            log_dict, plot_dict, target_df, clf = describe_ver(func, cat_col, numerical_col, sensi_atts, target_name, training, save_path)
            pickle.dump(clf, open(save_path+"/checkpoints/clf.p", "wb"))
            if training:
                pickle.dump(target_df, open(save_path+"/checkpoints/target_df_train.p", "wb"))
                pickle.dump(log_dict, open(save_path+"/checkpoints/log_dict_train.p", "wb"))
                pickle.dump(plot_dict, open(save_path+"/checkpoints/plot_dict_train.p", "wb"))
            else:
                pickle.dump(target_df, open(save_path+"/checkpoints/target_df_test.p", "wb"))
                pickle.dump(log_dict, open(save_path+"/checkpoints/log_dict_test.p", "wb"))
                pickle.dump(plot_dict, open(save_path+"/checkpoints/plot_dict_test.p", "wb"))
            log_list = []
            pd_graph, parent_vertices, log_list = pd_to_dataflow_graph(func, log_list)
            pipeline = func(*args, **kwargs)
            sklearn_graph, log_list = sklearn_to_dataflow_graph(pipeline, log_list, parent_vertices)
            pd_graph.extend(sklearn_graph)
            _, rand_rgb = visualize(pd_graph, log_list, save_path, dag_save)
            colors = dict(zip(log_list, rand_rgb))
            if training:
                pickle.dump(colors, open(save_path+"/checkpoints/rand_color_train.p", "wb"))
                pickle.dump(log_list, open(save_path+"/checkpoints/log_list_dag_train.p", "wb"))
            else:
                pickle.dump(colors, open(save_path+"/checkpoints/rand_color_test.p", "wb"))
                pickle.dump(log_list, open(save_path+"/checkpoints/log_list_dag_test.p", "wb"))
        return call
    return wrapper

    combines describe_ver(generate intermediate dict) and visualize(DAG generation).

    args:
        cat_col: catagorical attributes used for tracing changes. String.
        numerical_col: numerical attributes used for tracing changes. String.
        sensi_atts: sensible attributes used to generate static labels. String.
        target_name: target attributes. String.
        training: Indicator for training session. False to be testing. Used for classifier train/val. Bool.
        save_path: save_path specified to save intermediate dict files. String.
        dag_save: format of DAG to be saved. String.

    return:
        function wrapper. all outputs saved to save_path using pickle.

    


function wrapper. all outputs saved to save_path using pickle.
function wrapper . all outputs saved to save_path using pickle .
def tracer(cat_col, numerical_col, sensi_atts, target_name, training = True, save_path = '', dag_save = 'pdf'):
    def wrapper(func):
        def call(*args, **kwargs):
            if not os.path.exists('experiments'):
                os.mkdir('experiments')
            if not os.path.exists(save_path):
                os.mkdir(save_path)
            if not os.path.exists(save_path+'/checkpoints'):
                os.mkdir(save_path+'/checkpoints')
            if not os.path.exists(save_path+'/checkpoints/csv'):
                os.mkdir(save_path+'/checkpoints/csv')
            if training and not os.path.exists(save_path+'/checkpoints/csv/training'):
                os.mkdir(save_path+'/checkpoints/csv/training')
            if not training and not os.path.exists(save_path+'/checkpoints/csv/testing'):
                os.mkdir(save_path+'/checkpoints/csv/testing')
            log_dict, plot_dict, target_df, clf = describe_ver(func, cat_col, numerical_col, sensi_atts, target_name, training, save_path)
            pickle.dump(clf, open(save_path+"/checkpoints/clf.p", "wb"))
            if training:
                pickle.dump(target_df, open(save_path+"/checkpoints/target_df_train.p", "wb"))
                pickle.dump(log_dict, open(save_path+"/checkpoints/log_dict_train.p", "wb"))
                pickle.dump(plot_dict, open(save_path+"/checkpoints/plot_dict_train.p", "wb"))
            else:
                pickle.dump(target_df, open(save_path+"/checkpoints/target_df_test.p", "wb"))
                pickle.dump(log_dict, open(save_path+"/checkpoints/log_dict_test.p", "wb"))
                pickle.dump(plot_dict, open(save_path+"/checkpoints/plot_dict_test.p", "wb"))
            log_list = []
            pd_graph, parent_vertices, log_list = pd_to_dataflow_graph(func, log_list)
            pipeline = func(*args, **kwargs)
            sklearn_graph, log_list = sklearn_to_dataflow_graph(pipeline, log_list, parent_vertices)
            pd_graph.extend(sklearn_graph)
            _, rand_rgb = visualize(pd_graph, log_list, save_path, dag_save)
            colors = dict(zip(log_list, rand_rgb))
            if training:
                pickle.dump(colors, open(save_path+"/checkpoints/rand_color_train.p", "wb"))
                pickle.dump(log_list, open(save_path+"/checkpoints/log_list_dag_train.p", "wb"))
            else:
                pickle.dump(colors, open(save_path+"/checkpoints/rand_color_test.p", "wb"))
                pickle.dump(log_list, open(save_path+"/checkpoints/log_list_dag_test.p", "wb"))
        return call
    return wrapper
def tracer ( cat_col , numerical_col , sensi_atts , target_name , training = True , save_path = '' , dag_save = 'pdf' ) : def wrapper ( func ) : def call ( * args , ** kwargs ) : if not os . path . exists ( 'experiments' ) : os . mkdir ( 'experiments' ) if not os . path . exists ( save_path ) : os . mkdir ( save_path ) if not os . path . exists ( save_path + '/checkpoints' ) : os . mkdir ( save_path + '/checkpoints' ) if not os . path . exists ( save_path + '/checkpoints/csv' ) : os . mkdir ( save_path + '/checkpoints/csv' ) if training and not os . path . exists ( save_path + '/checkpoints/csv/training' ) : os . mkdir ( save_path + '/checkpoints/csv/training' ) if not training and not os . path . exists ( save_path + '/checkpoints/csv/testing' ) : os . mkdir ( save_path + '/checkpoints/csv/testing' ) log_dict , plot_dict , target_df , clf = describe_ver ( func , cat_col , numerical_col , sensi_atts , target_name , training , save_path ) pickle . dump ( clf , open ( save_path + "/checkpoints/clf.p" , "wb" ) ) if training : pickle . dump ( target_df , open ( save_path + "/checkpoints/target_df_train.p" , "wb" ) ) pickle . dump ( log_dict , open ( save_path + "/checkpoints/log_dict_train.p" , "wb" ) ) pickle . dump ( plot_dict , open ( save_path + "/checkpoints/plot_dict_train.p" , "wb" ) ) else : pickle . dump ( target_df , open ( save_path + "/checkpoints/target_df_test.p" , "wb" ) ) pickle . dump ( log_dict , open ( save_path + "/checkpoints/log_dict_test.p" , "wb" ) ) pickle . dump ( plot_dict , open ( save_path + "/checkpoints/plot_dict_test.p" , "wb" ) ) log_list = [ ] pd_graph , parent_vertices , log_list = pd_to_dataflow_graph ( func , log_list ) pipeline = func ( * args , ** kwargs ) sklearn_graph , log_list = sklearn_to_dataflow_graph ( pipeline , log_list , parent_vertices ) pd_graph . extend ( sklearn_graph ) _ , rand_rgb = visualize ( pd_graph , log_list , save_path , dag_save ) colors = dict ( zip ( log_list , rand_rgb ) ) if training : pickle . dump ( colors , open ( save_path + "/checkpoints/rand_color_train.p" , "wb" ) ) pickle . dump ( log_list , open ( save_path + "/checkpoints/log_list_dag_train.p" , "wb" ) ) else : pickle . dump ( colors , open ( save_path + "/checkpoints/rand_color_test.p" , "wb" ) ) pickle . dump ( log_list , open ( save_path + "/checkpoints/log_list_dag_test.p" , "wb" ) ) return call return wrapper
combines describe_ver(generate intermediate dict) and visualize(DAG generation).
combines describe_ver ( generate intermediate dict ) and visualize ( DAG generation ) .
"""
    combines describe_ver(generate intermediate dict) and visualize(DAG generation).

    args:
        cat_col: catagorical attributes used for tracing changes. String.
        numerical_col: numerical attributes used for tracing changes. String.
        sensi_atts: sensible attributes used to generate static labels. String.
        target_name: target attributes. String.
        training: Indicator for training session. False to be testing. Used for classifier train/val. Bool.
        save_path: save_path specified to save intermediate dict files. String.
        dag_save: format of DAG to be saved. String.

    return:
        function wrapper. all outputs saved to save_path using pickle.

    """
cat_col
numerical_col
sensi_atts
target_name
training
save_path
dag_save