File size: 1,050 Bytes
85e3d20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
import torch
import torch.nn.functional as F

from tqdm import tqdm

from torch_geometric.loader import NeighborLoader
from torch.optim.lr_scheduler import ReduceLROnPlateau
from torch_geometric.nn import MessagePassing, SAGEConv
from ogb.nodeproppred import Evaluator, PygNodePropPredDataset
import pandas as pd
import numpy as np


def get_score(submission_folder = "../env"):
    submission_path = os.path.join(submission_folder, "submission.csv")
    submission = pd.read_csv(submission_path)
    target_dataset = 'ogbn-arxiv'

    dataset = PygNodePropPredDataset(name=target_dataset, root='networks')
    data = dataset[0]
    split_idx = dataset.get_idx_split() 
            
    test_idx = split_idx['test']

            
    evaluator = Evaluator(name=target_dataset)
    y_true = data.y.cpu()

    submission = torch.tensor(np.array(submission))

    test_acc = evaluator.eval({
        'y_true': y_true[test_idx],
        'y_pred': submission,
    })['acc']

    return test_acc

if __name__ == "__main__":
    print(get_score())