Last active
November 3, 2020 11:00
-
-
Save lucienne999/3958ffcb7a4ec3a6e0d542b759367250 to your computer and use it in GitHub Desktop.
Plot_reg_all
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
import seaborn as sns | |
import pandas as pd | |
from scipy import stats | |
TotalMSELoss = [0.2830, 0.4853, 0.6963, 1.0990, 1.2796, 1.7281, 1.8727, 2.0605, 2.1643, 2.5878, 2.7190, 3.0497, 3.1828, 3.3756, 3.4804, 3.9982, 4.6670] | |
NewLoss = [1.3913, 1.4027, 1.4132, 1.4496, 1.4591, 1.4848, 1.4941, 1.5148, 1.5144, 1.5435, 1.5481, 1.5704, 1.5802, 1.5903, 1.5958, 1.6268, 1.6650] | |
Acc = [75.52 , 75.00 , 74.66 , 74.76 , 74.46 , 74.36 , 74.43 , 74.57 , 74.52 , 74.55 , 74.34 , 73.80 , 74.33 , 74.14 , 73.86 , 73.85 , 73.58] | |
MnasNet = [49.74, 49.22, 48.13, 48.02, 47.76, 46.91, 46.68, 47.74, 47.77, 48.23, 47.61, 46.83, 47.90, 46.80, 47.11, 46.61, 46.11] # lr=0.001 | |
MnasNet_2 = [1.78, 16.01, 9.78, 12.83, 17.48, 14.24, 15.73, 16.12, 13.36, 14.28, 14.97, 13.89, 13.57, 15.39, 15.03, 15.83, 13.47] # lr=0.2 | |
SuperNetInfer= [70.80 , 70.86 , 70.768, 70.704, 70.896, 70.796, 70.558, 70.62 , 70.892, 70.86 , 70.804, 70.848, 70.734, 70.918, 71.024, 70.746, 70.846 ] | |
TotalMSELoss = np.array(TotalMSELoss) | |
NewLoss = np.array(NewLoss) | |
MnasNet = np.array(MnasNet) | |
MnasNet_2 = np.array(MnasNet_2) | |
Acc = np.array(Acc) | |
SuperNetInfer = np.array(SuperNetInfer) | |
DataDict = {"Stand-Alone Model Accuracy": Acc, "Total Evaluation Loss (minus)": -NewLoss, 'Undertrained(0.001)': MnasNet, 'Undertrained(0.2)': MnasNet_2 , 'SPOS': SuperNetInfer} | |
DataFrame = pd.DataFrame(DataDict) | |
def set_axes(ax1, y1, y2, bias=(0,1,0.1)): | |
ax2 = ax1.twinx() | |
y1_data, y2_data = DataDict[y1], DataDict[y2] | |
print(y1_data, y2_data) | |
ax1.set_ylim([np.min(y1_data)-bias[0], np.max(y1_data)+bias[0]]) | |
ax2.set_ylim([np.min(y2_data)-bias[1], np.max(y2_data)+bias[1]]) | |
return ax1, ax2 | |
def plot_data(data, plot_cfg): | |
x_axis = "Stand-Alone Model Accuracy" | |
y_axis = [("Total Evaluation Loss (minus)", "DNA"), | |
("Undertrained(0.001)", "MnasNet_0.001"), ("Undertrained(0.2)", "MnasNet_0.2"), ("SPOS", "SPOS")] | |
print("Cal kendall tau") | |
dnatau = stats.kendalltau(DataDict[x_axis], DataDict[y_axis[0][0]]) | |
print("DNA :{}".format(dnatau)) | |
mnasNet1tau = stats.kendalltau(DataDict[x_axis], DataDict[y_axis[1][0]]) | |
print("MnasNet 0.001 :{}".format(mnasNet1tau)) | |
mnasNet2tau = stats.kendalltau(DataDict[x_axis], DataDict[y_axis[2][0]]) | |
print("MnasNet 0.2 :{}".format(mnasNet2tau)) | |
spostau = stats.kendalltau(DataDict[x_axis], DataDict[y_axis[3][0]]) | |
print("MnasNet 0.2 :{}".format(spostau)) | |
sns.set(style='white', palette='muted', color_codes=True) | |
sns.set(style='white') | |
colors = sns.color_palette('Set1', n_colors=5) | |
# using axes | |
f, axes = plt.subplots(1,4,figsize=(32,8)) | |
# plt.subplots_adjust(bottom=0.25, top=0.615, wspace=0.2, right=0.95, left=0.05) | |
ci = 98 | |
fontsize = 25 | |
axis_fsize = 18 | |
ax1,ax2,ax3,ax4 = axes[0], axes[1], axes[2], axes[3] | |
ax11, ax12 = set_axes(ax1, y_axis[0][0], y_axis[1][0], bias=(0.02, 0.1)) | |
sns.regplot(x = x_axis, y = y_axis[0][0], data = DataFrame, ax = ax11, label = y_axis[0][1]+'({0:.2f})'.format(dnatau.correlation), scatter_kws={'color':colors[0]}, line_kws={"color": colors[0]}, ci=ci) | |
ax21, ax22 = set_axes(ax2, y_axis[0][0], y_axis[3][0], bias=(0.02, 0.1)) | |
sns.regplot(x = x_axis, y = y_axis[0][0], data = DataFrame, ax = ax21, scatter_kws={'color':colors[0]}, line_kws={"color": colors[0]}, ci=ci) | |
sns.regplot(x = x_axis, y = y_axis[3][0], data = DataFrame, ax = ax22, label = y_axis[3][1]+'({0:.2f})'.format(spostau.correlation), scatter_kws={'color': colors[4]}, line_kws={"color": colors[4]}, ci=ci) | |
ax21.set_title('v.s. One-shot Based', fontsize=fontsize) | |
ax21.set_xlabel("") | |
ax21.set_ylabel("") | |
ax22.set_xlabel("") | |
ax22.set_ylabel("") | |
ax21.tick_params(labelsize=axis_fsize) | |
ax22.tick_params(labelsize=axis_fsize) | |
ax31, ax32 = set_axes(ax3, y_axis[0][0], y_axis[2][0], bias=(0.02, 0.1)) | |
sns.regplot(x = x_axis, y = y_axis[0][0], data = DataFrame, ax = ax31, scatter_kws={'color':colors[0]}, line_kws={"color": colors[0]}, ci=ci) | |
sns.regplot(x = x_axis, y = y_axis[2][0], data = DataFrame, ax = ax32, label = y_axis[2][1]+'({0:.2f})'.format(mnasNet2tau.correlation), scatter_kws={'color': colors[3]}, line_kws={"color": colors[3]}, ci=ci) | |
ax31.set_title('v.s. Undertrained(0.2)', fontsize=fontsize) | |
ax31.set_xlabel("") | |
ax31.set_ylabel("") | |
ax32.set_xlabel("") | |
ax32.set_ylabel("") | |
ax31.tick_params(labelsize=axis_fsize) | |
ax32.tick_params(labelsize=axis_fsize) | |
ax41, ax42 = set_axes(ax4, y_axis[0][0], y_axis[1][0], bias=(0.02, 0.1)) | |
sns.regplot(x = x_axis, y = y_axis[0][0], data = DataFrame, ax = ax41, scatter_kws={'color':colors[0]}, line_kws={"color": colors[0]}, ci=ci) | |
sns.regplot(x = x_axis, y = y_axis[1][0], data = DataFrame, ax = ax42, label = y_axis[1][1]+'({0:.2f})'.format(mnasNet1tau.correlation), scatter_kws={'color': colors[2]}, line_kws={"color": colors[2]}, ci=ci) | |
ax41.set_title('v.s. Undertrained(0.001)',fontsize=fontsize) | |
ax41.set_xlabel("") | |
ax41.set_ylabel("") | |
ax42.set_xlabel("") | |
ax42.set_ylabel("") | |
ax41.tick_params(labelsize=axis_fsize) | |
ax42.tick_params(labelsize=axis_fsize) | |
f.legend(loc=(0.87,0.08), fontsize=16) | |
plt.xticks(fontsize=axis_fsize) | |
plt.yticks(fontsize=axis_fsize) | |
# plt.setp(ax1.get_xticklabels(), visible=True) | |
f.tight_layout() | |
plt.savefig('./Allloss.pdf') | |
plt.show() | |
if __name__ == '__main__': | |
plot_data(data=None, plot_cfg=None) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment