-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yu Zhang
committed
Feb 14, 2021
1 parent
99686fc
commit d65c902
Showing
32 changed files
with
202 additions
and
398 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
name: MAG | ||
|
||
train: | ||
texts: /shared/data2/yuz9/MATCH/MATCH/data/MAG/train_texts.npy | ||
labels: /shared/data2/yuz9/MATCH/MATCH/data/MAG/train_labels.npy | ||
texts: MAG/train_texts.npy | ||
labels: MAG/train_labels.npy | ||
|
||
valid: | ||
size: 70534 | ||
|
||
test: | ||
texts: /shared/data2/yuz9/MATCH/MATCH/data/MAG/test_texts.npy | ||
texts: MAG/test_texts.npy | ||
|
||
embedding: | ||
emb_init: /shared/data2/yuz9/MATCH/MATCH/data/MAG/emb_init.npy | ||
emb_init: MAG/emb_init.npy | ||
|
||
hierarchy: MAG/taxonomy.txt | ||
|
||
output: | ||
res: /shared/data2/yuz9/MATCH/MATCH/data/MAG/results | ||
res: MAG/results | ||
|
||
labels_binarizer: /shared/data2/yuz9/MATCH/MATCH/data/MAG/labels_binarizer | ||
labels_binarizer: MAG/labels_binarizer | ||
|
||
model: | ||
emb_size: 100 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
name: MeSH | ||
|
||
train: | ||
texts: /shared/data2/yuz9/MATCH/MATCH/data/MeSH/train_texts.npy | ||
labels: /shared/data2/yuz9/MATCH/MATCH/data/MeSH/train_labels.npy | ||
texts: MeSH/train_texts.npy | ||
labels: MeSH/train_labels.npy | ||
|
||
valid: | ||
size: 89855 | ||
|
||
test: | ||
texts: /shared/data2/yuz9/MATCH/MATCH/data/MeSH/test_texts.npy | ||
texts: MeSH/test_texts.npy | ||
|
||
embedding: | ||
emb_init: /shared/data2/yuz9/MATCH/MATCH/data/MeSH/emb_init.npy | ||
emb_init: MeSH/emb_init.npy | ||
|
||
hierarchy: MeSH/taxonomy.txt | ||
|
||
output: | ||
res: /shared/data2/yuz9/MATCH/MATCH/data/MeSH/results | ||
res: MeSH/results | ||
|
||
labels_binarizer: /shared/data2/yuz9/MATCH/MATCH/data/MeSH/labels_binarizer | ||
labels_binarizer: MeSH/labels_binarizer | ||
|
||
model: | ||
emb_size: 100 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ valid: | |
predict: | ||
batch_size: 256 | ||
|
||
path: /shared/data2/yuz9/MATCH/MATCH/data/MAG/models | ||
path: MAG/models |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ valid: | |
predict: | ||
batch_size: 256 | ||
|
||
path: /shared/data2/yuz9/MATCH/MATCH/data/MeSH/models | ||
path: MeSH/models |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Binary file not shown.
Binary file not shown.
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
Empty file.
Empty file.
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
import warnings | ||
warnings.filterwarnings('ignore') | ||
|
||
import click | ||
import numpy as np | ||
from sklearn.preprocessing import MultiLabelBinarizer | ||
|
||
from deepxml.evaluation import get_p_1, get_p_3, get_p_5, get_n_1, get_n_3, get_n_5 | ||
|
||
@click.command() | ||
@click.option('-r', '--results', type=click.Path(exists=True), help='Path of results.') | ||
@click.option('-t', '--targets', type=click.Path(exists=True), help='Path of targets.') | ||
@click.option('--train-labels', type=click.Path(exists=True), default=None, help='Path of labels for training set.') | ||
|
||
def main(results, targets, train_labels): | ||
res, targets = np.load(results, allow_pickle=True), np.load(targets, allow_pickle=True) | ||
mlb = MultiLabelBinarizer(sparse_output=True) | ||
targets = mlb.fit_transform(targets) | ||
print('Precision@1,3,5:', get_p_1(res, targets, mlb), get_p_3(res, targets, mlb), get_p_5(res, targets, mlb)) | ||
print('nDCG@1,3,5:', get_n_1(res, targets, mlb), get_n_3(res, targets, mlb), get_n_5(res, targets, mlb)) | ||
|
||
if __name__ == '__main__': | ||
main() | ||
import warnings | ||
warnings.filterwarnings('ignore') | ||
|
||
import click | ||
import numpy as np | ||
from sklearn.preprocessing import MultiLabelBinarizer | ||
|
||
from deepxml.evaluation import get_p_1, get_p_3, get_p_5, get_n_1, get_n_3, get_n_5 | ||
|
||
@click.command() | ||
@click.option('-r', '--results', type=click.Path(exists=True), help='Path of results.') | ||
@click.option('-t', '--targets', type=click.Path(exists=True), help='Path of targets.') | ||
@click.option('--train-labels', type=click.Path(exists=True), default=None, help='Path of labels for training set.') | ||
|
||
def main(results, targets, train_labels): | ||
res, targets = np.load(results, allow_pickle=True), np.load(targets, allow_pickle=True) | ||
|
||
topk = 5 | ||
with open('predictions.txt', 'w') as fout: | ||
for labels in res: | ||
fout.write(' '.join(labels[:topk])+'\n') | ||
|
||
mlb = MultiLabelBinarizer(sparse_output=True) | ||
targets = mlb.fit_transform(targets) | ||
print('Precision@1,3,5:', get_p_1(res, targets, mlb), get_p_3(res, targets, mlb), get_p_5(res, targets, mlb)) | ||
print('nDCG@1,3,5:', get_n_1(res, targets, mlb), get_n_3(res, targets, mlb), get_n_5(res, targets, mlb)) | ||
|
||
if __name__ == '__main__': | ||
main() |
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
Oops, something went wrong.