<jupyter_start><jupyter_text>Mean Plots<jupyter_code>ls ../../../jlonevae/trainedModels/*/*/metrics
# combinedOutputs is the path from the root directory to the JL1-VAE models. 
# If unzipping pre-trained models you may need to change this path. 
# This path works for models trained and evaluated with
# ./experimentScripts/train_jlonevae/train_threeDots.bash
# ./experimentScripts/evaluate_jlonevae/evaluate_threeDots.bash
# which stores models and evaluations in directories like:
# ./trainedModels/defaultConv_lone_beta4_0000_ica0_1000_lat10_batch64_lr0_0001_anneal100000/20210604-014949/representation
combinedOutputs = "trainedModels"
# If unzipping pre-trained models you may need to change this path.
# For example, if you download "trainedThreeDotJL1Models.zip" and "trainedThreeDotJL2Models.zip"
# and unzip them into the directory "trainedThreeDotModelsBatches",
# then you should use filepath:
combinedOutputs = "trainedThreeDotModelsBatches"
# Gather evaluation results
evaluation_result_template = "{}/metrics/{}/results/aggregate/evaluation.json"
experiment_output_path = f"../../{combinedOutputs}"
for metric, metvalname in [("local_mig","evaluation_results.local_discrete_migs_samples"), 
               ("local_modularity","evaluation_results.local_modularity_scores_samples")]:
    for latdim in ["10"]:
        f = plt.figure(figsize=(10,8))
        bind = 1
        beta = "4"
        experiment_names = [
            (f"defaultConv_lone_beta4_0000_ica0_0000_lat10_batch64_lr0_0001_anneal100000", "black", "beta-VAE","-"),
            (f"defaultConv_lone_beta4_0000_ica0_0500_lat10_batch64_lr0_0001_anneal100000", red, "JL1-VAE(0.05)","--"),
            (f"defaultConv_lone_beta4_0000_ica0_1000_lat10_batch64_lr0_0001_anneal100000", red, "JL1-VAE(0.1)","-."),
            (f"defaultConv_lone_beta4_0000_ica0_2000_lat10_batch64_lr0_0001_anneal100000", red, "JL1-VAE(0.2)",(0, (3, 5, 1, 5, 1, 5))),
            (f"defaultConv_lone_beta4_0000_ica0_4000_lat10_batch64_lr0_0001_anneal100000", red, "JL1-VAE(0.4)",(0, (3, 5, 1, 5, 1, 5, 1, 5))),
            (f"defaultConv_jltwo_beta4_0000_ica0_0500_lat10_batch64_lr0_0001_anneal100000", blue, "JL2-VAE(0.05)",":"),
            (f"defaultConv_jltwo_beta4_0000_ica0_1000_lat10_batch64_lr0_0001_anneal100000", blue, "JL2-VAE(0.1)",(0, (1,5))),
            (f"defaultConv_jltwo_beta4_0000_ica0_2000_lat10_batch64_lr0_0001_anneal100000", blue, "JL2-VAE(0.2)",(0, (1,1, 1, 5))),
            (f"defaultConv_jltwo_beta4_0000_ica0_4000_lat10_batch64_lr0_0001_anneal100000", blue, "JL2-VAE(0.4)",(0, (1,1,1,1,1,5)))
                           ]
        data = []
        for experiment_name, color, metlabel, linestyle in experiment_names:
            evaluation_filepaths = glob.glob(f"{experiment_output_path}/{experiment_name}/*/metrics/{metric}*/results/aggregate/evaluation.json")
            for ind, filename in enumerate(evaluation_filepaths):
                if "2021060" in filename:
                    continue
                else: 
                    pass#print(filename)
                #print(filename,label)
                evaluation_results = json.loads(
                        open(filename, "r").read())
                locality = float(evaluation_results["evaluation_config.local_sample_factors.locality_proportion"])
                met_samps = evaluation_results[metvalname]
                data.append((metlabel, locality, np.mean(met_samps)))
                #if bind == 0 and ind == 0 and enind < 2:
                #    plt.plot(locality, np.mean(met_samps), markerfacecolor=(1, 1, 1, 0), markeredgecolor=color, markeredgewidth=2, marker=marker,label=label, markersize=markersize,linestyle="None" )
                #else:
                #    plt.plot(locality, np.mean(met_samps), markerfacecolor=(1, 1, 1, 0), markeredgecolor=color, markeredgewidth=2, marker=marker, markersize=markersize,linestyle="None" )


            import scipy.stats
            allLocalities = [0.1, 0.2, 0.3, 0.6, 1.0]
            avgMetVals = []
            lowMetVals = []
            highMetVals = []
            for desiredLocality in allLocalities:
                metvals = [metval for (label, locality, metval) in data if label == metlabel and locality == desiredLocality]
                print(len(metvals), metlabel)
                avgMetVals.append(np.mean(metvals))
                highMetVals.append(np.mean(metvals) + 2 * np.std(metvals))
                lowMetVals.append(np.mean(metvals) - 2 * np.std(metvals))
                #print(scipy.stats.ttest_ind(betametvals, lirjmetvals))
            plt.plot(allLocalities, avgMetVals, color=color,label=metlabel, linestyle=linestyle)
            plt.fill_between(allLocalities, lowMetVals, highMetVals, color=color, alpha=.1)
        plt.ylabel(metric.replace("_"," ").replace("mig","MIG"))
        plt.xlabel("Locality radius (fraction of factor range)");
        plt.xlim(-0.05,1.05)
        plt.legend()
        plt.tight_layout()
        f.savefig(f"L1L2_threeDots_{metric}_varyingRho.png")
        plt.show();plt.close();<jupyter_output>findfont: Font family ['normal'] not found. Falling back to DejaVu Sans.
{'fraction_non_alphanumeric': 0.12159533073929961, 'fraction_numerical': 0.07237354085603113, 'mean_word_length': 3.316540722082284, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '511161', 'license': 'Apache-2.0', 'n_tokens_mistral': 2002, 'n_tokens_neox': 1741, 'n_words': 287, 'path': 'experimentScripts/visualizations/AppendixLinePlotMIGandModularityL1VsL2.ipynb', 'repo_name': 'travers-rhodes/neurips2021_jlonevae_sanitized', 'size': '5140'}