Skip to content
DeepForgeby svx
All problems
EasyGraph Algorithmsgraph-139

Partition Accuracy vs Ground Truth

Problem

Measure how well a predicted partition matches ground truth labels by node-wise agreement.

Return the fraction of positions where predicted equals truth, or 0.0 when the lists are empty. predicted and truth are equal-length label lists.

Hint

Node-wise accuracy is strict about label identity, unlike NMI.

Test cases

case 1
in: [[0,0,1,1],[0,0,1,1]]
expected: 1
case 2
in: [[0,0,1,1],[0,1,0,1]]
expected: 0.5
case 3
in: [[0,1,2],[0,1,2]]
expected: 1
case 4
in: [[0,1],[1,0]]
expected: 0
case 5
in: [[],[]]
expected: 0
Starter codePython
def partition_accuracy(predicted, truth):
    # Your code here
    pass

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