Skip to content
DeepForgeby svx
All problems
MediumGraph Algorithmsgraph-197

Node Classification Accuracy

Problem

Compute the accuracy of node classification predictions.

Return the fraction of nodes where predictions equals labels, or 0.0 when the lists are empty. predictions and labels are equal-length lists of labels, typically integers.

Hint

Accuracy is the micro-level companion of partition similarity scores.

Test cases

case 1
in: [[0,1,1,0],[0,1,1,1]]
expected: 0.75
case 2
in: [[1,0],[1,1]]
expected: 0.5
case 3
in: [[5],[5]]
expected: 1
case 4
in: [[],[]]
expected: 0
Starter codePython
def node_classification_accuracy(predictions, labels):
    # Your code here
    pass

4 test cases · run your code against them in the editor