score_tra_path = '/home/chengtao/june/simple_exp/score/tra'
score_tes_path = '/home/chengtao/june/simple_exp/score/tes'
model_path     = '/home/chengtao/june/simple_exp/model'
data_tra_path  = '/home/chengtao/june/data/svm_pos/tra'
data_dev_path  = '/home/chengtao/june/data/svm_pos/dev'
data_tes_path  = '/home/chengtao/june/data/svm_pos/tes'

plt = plot_det.beg_plt()
plt.xlim([0,0.05])
plt.ylim([150,350])


best_hype = '16_3_0.001'
#plot_det.sco_plt(data_dev_path+'/targets_utt.ark',logr_path+'/0.001/score/posteri_utt.ark','logr 0.001')
#plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lstm_path+'/'+best_hype+'/score/posteri_seq.ark','lstm '+ best_hype)
#plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_hmm.pkl','hmm: 1st stage')
#plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_svm.pkl','svm: 2nd stage')
#plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lst2_path+'/200_100_16_2_0.001/score/posteri_seq.ark','lstm_lstm 200_100_16_2_0.001')
#plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lst3_path+'/500_100_64_1_0.0005/score/posteri_seq.ark','lstm_three 500_100_64_1_0.0005')
#plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lst4_path+'/'+best_hype+'/score/posteri_seq.ark','lstm '+ best_hype)
#plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lst5_path+'/'+best_hype+'/score/posteri_seq.ark','lstm '+ best_hype+' neg')
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lst6_path+'/'+best_hype+'/score/posteri_seq.ark','lstm '+ best_hype)
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_cld.pkl','cloud operating point',True)


#lgd = plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3, mode="expand", borderaxespad=0.)
#plt.savefig(sys.argv[0][:-3]+'.png',bbox_extra_artists=(lgd,), bbox_inches='tight')

plot_det.end_plt(sys.argv[0][:-3]+'.png')
import X_obj
import plot_det
import os
import sys
lstm_path      = '/home/chengtao/june/hyper/lstm'
logr_path      = '/home/chengtao/june/hyper/logr'
lst2_path      = '/home/chengtao/june/hyper/lstm_lstm'
lst3_path      = '/home/chengtao/june/hyper/lstm_three'
score_tra_path = '/home/chengtao/june/simple_exp/score/tra'
score_tes_path = '/home/chengtao/june/simple_exp/score/tes'
model_path     = '/home/chengtao/june/simple_exp/model'
data_tra_path  = '/home/chengtao/june/data/svm_pos/tra'
data_dev_path  = '/home/chengtao/june/data/svm_pos/dev'
data_tes_path  = '/home/chengtao/june/data/svm_pos/tes'

plot_det.beg_plt()

best_hype = '16_3_0.001'
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',logr_path+'/0.001/score/posteri_utt.ark','logr 0.001')
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lstm_path+'/'+best_hype+'/score/posteri_seq.ark','lstm '+ best_hype)
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_hmm.pkl','hmm: 1st stage')
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_svm.pkl','svm: 2nd stage')
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lst2_path+'/200_100_16_2_0.001/score/posteri_seq.ark','lstm_lstm 200_100_16_2_0.001')
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lst3_path+'/500_100_64_1_0.0005/score/posteri_seq.ark','lstm_three 500_100_64_1_0.0005')
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_cld.pkl','cloud operating point',True)

plot_det.end_plt('2015-1027-1807.png')
plot_det.beg_plt()

best = 0.00
best_hype = ''
for sco in sorted(os.listdir(lstm_path)):
    if 'info' in sco: continue
    if  sys.argv[1] not in sco: continue
    H = X_obj.SCO_obj(lstm_path+'/'+sco+'/score')
    auc,fpr,tpr = H.read_report()
    if auc > best:
        best = auc
        best_hype  = sco
    #plot_det.get_plt(auc,fpr,tpr,'lstm '+sco)
    

H = X_obj.SCO_obj(logr_path+'/0.001/score')
auc,fpr,tpr = H.read_report()
plot_det.get_plt(auc,fpr,tpr,'logr 0.001')

H = X_obj.SCO_obj(lstm_path+'/'+best_hype+'/score')
auc,fpr,tpr = H.read_report()
plot_det.get_plt(auc,fpr,tpr,'lstm 16_3_0.001')
print best_hype

plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_hmm.pkl','hmm: 1st stage')
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_svm.pkl','svm: 2nd stage')
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_cld.pkl','cloud operating point',True)

plot_det.end_plt('2015-1027-1207_{}.png'.format(sys.argv[1]))
plt.ylim([150, 350])


best_hype = "16_3_0.001"
plot_det.sco_plt(data_dev_path + "/targets_utt.ark", logr_path + "/0.001/score/posteri_utt.ark", "logr 0.001")
plot_det.sco_plt(
    data_dev_path + "/targets_utt.ark", lstm_path + "/" + best_hype + "/score/posteri_seq.ark", "lstm " + best_hype
)
plot_det.sco_plt(data_dev_path + "/targets_utt.ark", data_dev_path + "/results_hmm.pkl", "hmm: 1st stage")
plot_det.sco_plt(data_dev_path + "/targets_utt.ark", data_dev_path + "/results_svm.pkl", "svm: 2nd stage")
# plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lst2_path+'/200_100_16_2_0.001/score/posteri_seq.ark','lstm_lstm 200_100_16_2_0.001')
# plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lst3_path+'/500_100_64_1_0.0005/score/posteri_seq.ark','lstm_three 500_100_64_1_0.0005')
# plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lst4_path+'/'+best_hype+'/score/posteri_seq.ark','lstm '+ best_hype)
plot_det.sco_plt(
    data_dev_path + "/targets_utt.ark",
    lst5_path + "/" + best_hype + "/score/posteri_seq.ark",
    "lstm " + best_hype + " neg",
)
plot_det.sco_plt(
    data_dev_path + "/targets_utt.ark",
    lst6_path + "/" + best_hype + "/score/posteri_seq.ark",
    "lstm " + best_hype + " pretrain",
)
plot_det.sco_plt(data_dev_path + "/targets_utt.ark", data_dev_path + "/results_cld.pkl", "cloud operating point", True)


# lgd = plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3, mode="expand", borderaxespad=0.)
# plt.savefig(sys.argv[0][:-3]+'.png',bbox_extra_artists=(lgd,), bbox_inches='tight')

plot_det.end_plt(sys.argv[0][:-3] + ".png")
import X_obj
import plot_det
import os
import sys
lstm_path     = '/home/chengtao/june/hyper/lstm'
logr_path     = '/home/chengtao/june/hyper/logr'
score_tra_path = '/home/chengtao/june/simple_exp/score/tra'
score_tes_path = '/home/chengtao/june/simple_exp/score/tes'
model_path     = '/home/chengtao/june/simple_exp/model'
data_tra_path  = '/home/chengtao/june/data/svm_pos/tra'
data_dev_path  = '/home/chengtao/june/data/svm_pos/dev'
data_tes_path  = '/home/chengtao/june/data/svm_pos/tes'

plot_det.beg_plt()

best_hype = '16_3_0.001'
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',logr_path+'/0.001/score/posteri_utt.ark','logr 0.001')
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',lstm_path+'/'+best_hype+'/score/posteri_seq.ark','lstm '+ best_hype)
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_hmm.pkl','hmm: 1st stage')
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_svm.pkl','svm: 2nd stage')
plot_det.sco_plt(data_dev_path+'/targets_utt.ark',data_dev_path+'/results_cld.pkl','cloud operating point',True)

plot_det.end_plt('2015-1027-1716.png')