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

adaptation windows

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