pygip.utils¶
- class pygip.utils.GraphNeuralNetworkMetric(fidelity=0, accuracy=0, model=None, graph=None, features=None, mask=None, labels=None, query_labels=None)[source]¶
Bases:
object
Graph Neural Network Metric Class.
This class evaluates two metrics, fidelity and accuracy, for a given GNN model on a specified graph and features.
- static calculate_surrogate_fidelity(target_model, surrogate_model, data, mask=None)[source]¶
Calculate fidelity between target and surrogate model predictions.
- Parameters:
target_model – Original model
surrogate_model – Extracted surrogate model
data – Input graph data
mask – Optional mask for evaluation on specific nodes
- Returns:
Fidelity score (percentage of matching predictions)
- Return type:
float
- evaluate_helper(model, graph, features, labels, mask)[source]¶
Helper function to evaluate the model’s performance.
- static evaluate_surrogate_extraction(target_model, surrogate_model, data, train_mask=None, val_mask=None, test_mask=None)[source]¶
Comprehensive evaluation of surrogate extraction attack.
- Parameters:
target_model – Original model
surrogate_model – Extracted surrogate model
data – Input graph data
train_mask – Mask for training nodes
val_mask – Mask for validation nodes
test_mask – Mask for test nodes
- Returns:
Dictionary containing fidelity scores for different data splits
- Return type:
dict
Modules