def generate_all_embedders(dTSNE_mnist): _, _, lion_optimal_powers = exp_lion_power_performance.load_lion_power_plot() embedders = dict() # Changing random state to make sure letter_As do not overlap for p in lion_percentiles: embedders["LION-"+str(p)+"-"+str(round(lion_optimal_powers[p], n_digits))] = \ dTSNE_mnist.generate_embedding_function(random_state=p, function_kwargs={'radius_x_percentile':p, 'power': lion_optimal_powers[p], 'radius_y_close_percentile': 100, 'y_safety_margin': 0}) logging.info("Generated embedder LION-%d (%f)",p, lion_optimal_powers[p]) return embedders
lion_optimal_power = dict() font_properties = FontProperties() font_properties.set_family('serif') font_properties.set_name('Times New Roman') font_properties.set_size(8) legend_list = list() plt.figure(dpi=300) plt.gcf().set_size_inches(3.3, 2.5) lion_power_plot_data = exp_lion_power_performance.load_lion_power_performance() global_idw_power_performance, global_idw_power_performance_abs, _, _ = exp_idw_power_performance.load_idw_power_performance() x_global, y_global, _ = exp_idw_power_performance.load_idw_power_plot() x, y, _ = exp_lion_power_performance.load_lion_power_plot() power_perc_combos = lion_power_plot_data.keys() # print(power_perc_combos) all_percentages = set([int(i.split(";")[0]) for i in power_perc_combos]) #x = sorted(set([float(i.split(";")[1]) for i in power_perc_combos])) color_dict = {90: 'blue', 95: 'green', 99: 'red', 100: 'cyan'} legend_list = list() legend_lines = list() # print(all_percentages) for perc in all_percentages: h, = plt.plot(x, y[perc], c=color_dict[perc]) legend_lines.append(h) legend_list.append("$r_x$: " + str(perc) + " NN percentile")
def main(*, regenerate=False, parameters=settings.parameters): start_time = datetime.datetime.now() logging.info("LION debug letter experiment started: %s", start_time) common_info = get_common_info(parameters) results = dict() embedders = generate_all_embedders(common_info['dTSNE_mnist']) for embedder_name in embedders.keys(): process_single_embedder(embedder=embedders[embedder_name], embedder_name=embedder_name, results=results, regenerate=regenerate, common_info=common_info, parameters=parameters) end_time = datetime.datetime.now() logging.info("letter experiment ended: %s", end_time) logging.info("letter experiment duration: %s", end_time-start_time) _, _, lion_optimal_power = exp_lion_power_performance.load_lion_power_plot() lion_method_list = ["LION; $r_x$ at %dth perc.; $p$=%.1f" % (i, lion_optimal_power[i]) for i in sorted(lion_optimal_power)] lion90_name = [i for i in results.keys() if i.startswith('LION-90')][0] letters_y_lion90 = results[lion90_name]['EmbeddedPoints'] lion95_name = [i for i in results.keys() if i.startswith('LION-95')][0] letters_y_lion95 = results[lion95_name]['EmbeddedPoints'] lion99_name = [i for i in results.keys() if i.startswith('LION-99')][0] letters_y_lion99 = results[lion99_name]['EmbeddedPoints'] lion100_name = [i for i in results.keys() if i.startswith('LION-100')][0] letters_y_lion100 = results[lion100_name]['EmbeddedPoints'] cur_shown_letter_indices_begin = 0 cur_shown_letter_indices_end = 20 #for k in ['LION-90-16.4']: # embedders.keys(): # print(k ,embedders[k](common_info['letter_samples'] # [cur_shown_letter_indices_begin:cur_shown_letter_indices_end])) embedding_function = common_info['dTSNE_mnist'].generate_lion_tsne_embedder( function_kwargs={'radius_x_percentile': 90, 'power': 16.4}, random_state=90, verbose=2) #print(embedding_function( # common_info['letter_samples'][cur_shown_letter_indices_begin:cur_shown_letter_indices_end], verbose=2)) #print("\n\n\n") #print(letters_y_lion90[cur_shown_letter_indices_begin:cur_shown_letter_indices_end, :]) Y_mnist = generate_data.load_y_mnist(parameters=parameters) point_size_gray = 10 point_size_interest = 15 plt.figure(dpi=300) plt.gcf().set_size_inches(6.8, 6.8) font_properties = FontProperties() font_properties.set_family('serif') font_properties.set_name('Times New Roman') font_properties.set_size(8) plt.scatter(Y_mnist[:, 0], Y_mnist[:, 1], c= 'gray', zorder=1, label=None, marker='.', s = point_size_gray) h1 = plt.scatter(letters_y_lion90[cur_shown_letter_indices_begin:cur_shown_letter_indices_end, 0], letters_y_lion90[cur_shown_letter_indices_begin:cur_shown_letter_indices_end, 1], c='red', zorder=1, label=None, marker='.', s = point_size_interest) h2 = plt.scatter(letters_y_lion95[cur_shown_letter_indices_begin:cur_shown_letter_indices_end, 0], letters_y_lion95[cur_shown_letter_indices_begin:cur_shown_letter_indices_end, 1], c='blue', zorder=1, label=None, marker='.', s = point_size_interest) h3 = plt.scatter(letters_y_lion99[cur_shown_letter_indices_begin:cur_shown_letter_indices_end, 0], letters_y_lion99[cur_shown_letter_indices_begin:cur_shown_letter_indices_end, 1], c='green', zorder=1, label=None, marker='.', s = point_size_interest) h4 = plt.scatter(letters_y_lion100[cur_shown_letter_indices_begin:cur_shown_letter_indices_end, 0], letters_y_lion100[cur_shown_letter_indices_begin:cur_shown_letter_indices_end, 1], c='purple', zorder=1, label=None, marker='.', s = point_size_interest) plt.legend([h1,h2,h3,h4], lion_method_list, ncol=1, prop=font_properties, borderpad=0.1,handlelength=2, columnspacing = 0, loc = 1, handletextpad=-0.7,frameon=True) plt.show()
def main(*, regenerate=False, parameters=settings.parameters): start_time = datetime.datetime.now() logging.info("IDW/RBF/LION letter_A experiment started: %s", start_time) common_info = get_common_info(parameters) results = dict() embedders = generate_all_embedders(common_info['dTSNE_mnist']) for embedder_name in embedders.keys(): process_single_embedder(embedder=embedders[embedder_name], embedder_name=embedder_name, results=results, regenerate=regenerate, common_info=common_info, parameters=parameters) end_time = datetime.datetime.now() logging.info("letter_A experiment ended: %s", end_time) logging.info("letter_A experiment duration: %s", end_time - start_time) _, _, lion_optimal_power = exp_lion_power_performance.load_lion_power_plot( ) lion_method_list = [ "LION; $r_x$ at %dth perc.; $p$=%.1f" % (i, lion_optimal_power[i]) for i in sorted(lion_optimal_power) ] lion90_name = [i for i in results.keys() if i.startswith('LION-90')][0] letter_As_y_lion90 = results[lion90_name]['EmbeddedPoints'] lion95_name = [i for i in results.keys() if i.startswith('LION-95')][0] letter_As_y_lion95 = results[lion95_name]['EmbeddedPoints'] lion99_name = [i for i in results.keys() if i.startswith('LION-99')][0] letter_As_y_lion99 = results[lion99_name]['EmbeddedPoints'] lion100_name = [i for i in results.keys() if i.startswith('LION-100')][0] letter_As_y_lion100 = results[lion100_name]['EmbeddedPoints'] Y_mnist = generate_data.load_y_mnist(parameters=parameters) point_size_gray = 10 cur_shown_letter_A_indices = 100 point_size_interest = 15 plt.figure(dpi=300) plt.gcf().set_size_inches(6.8, 6.8) font_properties = FontProperties() font_properties.set_family('serif') font_properties.set_name('Times New Roman') font_properties.set_size(8) plt.scatter(Y_mnist[:, 0], Y_mnist[:, 1], c='gray', zorder=1, label=None, marker='.', s=point_size_gray) h1 = plt.scatter(letter_As_y_lion90[:cur_shown_letter_A_indices, 0], letter_As_y_lion90[:cur_shown_letter_A_indices, 1], c='red', zorder=1, label=None, marker='.', s=point_size_interest) h2 = plt.scatter(letter_As_y_lion95[:cur_shown_letter_A_indices, 0], letter_As_y_lion95[:cur_shown_letter_A_indices, 1], c='blue', zorder=1, label=None, marker='.', s=point_size_interest) h3 = plt.scatter(letter_As_y_lion99[:cur_shown_letter_A_indices, 0], letter_As_y_lion99[:cur_shown_letter_A_indices, 1], c='green', zorder=1, label=None, marker='.', s=point_size_interest) h4 = plt.scatter(letter_As_y_lion100[:cur_shown_letter_A_indices, 0], letter_As_y_lion100[:cur_shown_letter_A_indices, 1], c='purple', zorder=1, label=None, marker='.', s=point_size_interest) plt.legend([h1, h2, h3, h4], lion_method_list, ncol=1, prop=font_properties, borderpad=0.1, handlelength=2, columnspacing=0, loc=1, handletextpad=-0.7, frameon=True) plt.show()