Click4Ai

464.

Medium

Node Classification is a common task in Graph Neural Networks. Implement a function to perform node classification on a graph using NumPy. **Example:** Given an input graph represented as an adjacency matrix A and node features X, perform node classification to obtain the predicted labels y_pred. **Constraints:** The graph is undirected and unweighted. The node features are represented as a matrix where each row corresponds to a node. The adjacency matrix A is symmetric. The labels are represented as a vector where each element corresponds to a node.

**Hint:** Use the formula y_pred = softmax(X @ W) to perform node classification.

Test Cases

Test Case 1
Input: [[0, 1, 1], [1, 0, 1], [1, 1, 0]]
Expected: [[0.5, 0.5], [0.5, 0.5], [0.5, 0.5]]
Test Case 2
Input: [[0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]]
Expected: [[0.25, 0.25, 0.25, 0.25], [0.25, 0.25, 0.25, 0.25], [0.25, 0.25, 0.25, 0.25], [0.25, 0.25, 0.25, 0.25]]
+ 3 hidden test cases