17.3.12 Inferring Edge Labels for a Supervised EdgeWise Model

You can infer the edge labels on any graph (including edges or graphs that were not seen during training):

opg4j> var labels = model.infer(fullGraph, testEdges)
opg4j> labels.head().print()
PgxFrame labels = model.infer(fullGraph, testEdges);
labels.head().print();
labels = model.infer(full_graph,test_edges)
labels.print()

If the loss is SigmoidCrossEntropy or DevNetLoss, then it is also possible to set the decision threshold applied to the logits by adding it as an extra parameter, which is by default 0:

opg4j> var labels = model.infer(fullGraph, testEdges, 6f)
opg4j> labels.head().print()
PgxFrame labels = model.infer(fullGraph,testEdges,6f);
labels.head().print();
labels = model.infer(full_graph, full_graph.get_edges(), 6)
labels.print()

The output will be similar to the following example output:

+-----------------------------+
| edgeId | value              |
+-----------------------------+
| 68472  | 2.2346956729888916 |
| 53436  | 2.1515913009643555 |
| 73364  | 1.9499346017837524 |
| 12096  | 2.1704165935516357 |
| 78740  | 2.1174447536468506 |
| 27664  | 2.1041007041931152 |
| 34844  | 2.148571491241455  |
| 74224  | 2.089123010635376  |
| 33744  | 2.0866644382476807 |
| 32812  | 2.0604987144470215 |
+-----------------------------+

Similarly, if the task is a classification task, you can get the model confidence for each class by inferring the prediction logits:

opg4j> var logits = model.inferLogits(fullGraph, testEdges)
opg4j> logits.head().print()
PgxFrame logits = model.inferLogits(fullGraph,testEdges);
logits.head().print();
logits = model.infer_logits(full_graph, test_edges)
logits.print()

If the model is a classification model, the inferLabels method is also available and it is equivalent to the infer methoid.