提交 2cf8c6f0 编写于 作者: Y yinhaofeng

adaptation windows

上级 99796045
......@@ -13,11 +13,7 @@
# limitations under the License.
#!/bin/bash
echo "................run................."
python -m paddlerec.run -m ./config.yaml &> result1.txt
grep -i "query_doc_sim" ./result1.txt >./result2.txt
sed '$d' result2.txt >result.txt
rm -f result1.txt
rm -f result2.txt
python -m paddlerec.run -m ./config.yaml &> result.txt
python transform.py
sort -t $'\t' -k1,1 -k 2nr,2 pair.txt >result.txt
rm -f pair.txt
......
......@@ -16,6 +16,20 @@ import random
import numpy as np
import sklearn.metrics
filename = './result.txt'
f = open(filename, "r")
lines = f.readlines()
f.close()
result = []
for line in lines:
if "query_doc_sim" in str(line):
result.append(line)
result = result[:-1]
f = open(filename, "w")
for i in range(len(result)):
f.write(str(result[i]))
f.close()
label = []
filename = './data/label.txt'
f = open(filename, "r")
......
......@@ -32,6 +32,20 @@ def eval_MAP(pred, gt):
return map_value / r
filename = './result.txt'
f = open(filename, "r")
lines = f.readlines()
f.close()
result = []
for line in lines:
if "prediction" in str(line):
result.append(line)
result = result[:-1]
f = open(filename, "w")
for i in range(len(result)):
f.write(str(result[i]))
f.close()
filename = './data/relation.test.fold1.txt'
gt = []
qid = []
......@@ -56,7 +70,7 @@ for line in open(filename):
pred.append(float(line))
result_dict = {}
for i in range(len(qid)):
for i in range(len(pred)):
if qid[i] not in result_dict:
result_dict[qid[i]] = []
result_dict[qid[i]].append([gt[i], pred[i]])
......
#!/bin/bash
echo "................run................."
python -m paddlerec.run -m ./config.yaml &>result1.txt
grep -i "prediction" ./result1.txt >./result2.txt
sed '$d' result2.txt >result.txt
rm -f result2.txt
rm -f result1.txt
python -m paddlerec.run -m ./config.yaml &>result.txt
python eval.py
......@@ -14,12 +14,8 @@
#!/bin/bash
echo "................run................."
python -m paddlerec.run -m ./config.yaml &>result1.txt
grep -i "query_pt_sim" ./result1.txt >./result2.txt
sed '$d' result2.txt >result.txt
rm -f result1.txt
rm -f result2.txt
python -m paddlerec.run -m ./config.yaml &>result.txt
python transform.py
sort -t $'\t' -k1,1 -k 2nr,2 pair.txt >result.txt
sort -t $'\t' -k1,1 -k 2nr,2 pair.txt &>result.txt
rm -f pair.txt
python ../../../tools/cal_pos_neg.py result.txt
......@@ -15,6 +15,20 @@
import random
import numpy as np
filename = './result.txt'
f = open(filename, "r")
lines = f.readlines()
f.close()
result = []
for line in lines:
if "query_pt_sim" in str(line):
result.append(line)
result = result[:-1]
f = open(filename, "w")
for i in range(len(result)):
f.write(str(result[i]))
f.close()
label = []
filename = './data/label.txt'
f = open(filename, "r")
......@@ -31,7 +45,7 @@ filename = './result.txt'
sim = []
for line in open(filename):
line = line.strip().split(",")
print(line)
#print(line)
line[3] = line[3].split(":")
line = line[3][1].strip(" ")
line = line.strip("[")
......@@ -50,6 +64,6 @@ f.close()
filename = 'pair.txt'
f = open(filename, "w")
for i in range(len(sim)):
print(i)
#print(i)
f.write(str(query[i]) + "\t" + str(sim[i]) + "\t" + str(label[i]) + "\n")
f.close()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册