Standard PolyGraphDiscrepancy

StandardPGD is a PolyGraphDiscrepancy metric based on six different graph descriptors.

By default, we use TabPFN for binary classification and evaluate it by data log-likelihood, obtaining a PolyGraphDiscrepancy that provides an estimated lower bound on the Jensen-Shannon distance between the generated and true graph distribution.

This metric is implemented in the StandardPGD class and can be used as follows:

from polygraph.datasets import PlanarGraphDataset, SBMGraphDataset
from polygraph.metrics import StandardPGD

reference = PlanarGraphDataset("val").to_nx()
generated = SBMGraphDataset("val").to_nx()

benchmark = StandardPGD(reference)
print(benchmark.compute(generated))     # {'pgd': 0.9902651620251016, 'pgd_descriptor': 'clustering', 'subscores': {'orbit': 0.9962500491652303, 'clustering': 0.9902651620251016, 'degree': 0.9975117559449073, 'spectral': 0.9634302070519823, 'gin': 0.994213920319544}}

We also provide classes that implement individual ClassifierMetrics:

StandardPGD

polygraph.metrics.StandardPGD

Bases: PolyGraphDiscrepancy[Graph]

PolyGraphDiscrepancy metric that combines six different graph descriptors.

By default, we use TabPFN for binary classification and evaluate it by data log-likelihood, obtaining a PolyGraphDiscrepancy that provides an estimated lower bound on the Jensen-Shannon distance between the generated and true graph distribution.

Parameters:
  • reference_graphs (Collection[Graph]) –

    Collection of reference networkx graphs.

polygraph.metrics.StandardPGDInterval

Bases: PolyGraphDiscrepancyInterval[Graph]

StandardPGD with uncertainty quantification.

Parameters:
  • reference_graphs (Collection[Graph]) –

    Collection of reference networkx graphs.

  • subsample_size (int) –

    Size of each subsample, should be consistent with the number of reference and generated graphs passed to PolyGraphDiscrepancy for point estimates.

  • num_samples (int, default: 10 ) –

    Number of samples to draw for uncertainty quantification.

Individual Classifier Metrics

polygraph.metrics.standard_pgd.ClassifierOrbit4Metric

Bases: ClassifierMetric[Graph]

Classifier metric based on OrbitCounts.

Parameters:
  • reference_graphs (Collection[Graph]) –

    Collection of reference networkx graphs.

  • variant (Literal['informedness', 'jsd'], default: 'jsd' ) –

    Probability metric to approximate.

  • classifier (Optional[ClassifierProtocol], default: None ) –

    Binary classifier to fit.

polygraph.metrics.standard_pgd.ClassifierOrbit5Metric

Bases: ClassifierMetric[Graph]

Classifier metric based on OrbitCounts.

Parameters:
  • reference_graphs (Collection[Graph]) –

    Collection of reference networkx graphs.

  • variant (Literal['informedness', 'jsd'], default: 'jsd' ) –

    Probability metric to approximate.

  • classifier (Optional[ClassifierProtocol], default: None ) –

    Binary classifier to fit.

polygraph.metrics.standard_pgd.ClassifierDegreeMetric

Bases: ClassifierMetric[Graph]

Classifier metric based on SparseDegreeHistogram.

Parameters:
  • reference_graphs (Collection[Graph]) –

    Collection of reference networkx graphs.

  • variant (Literal['informedness', 'jsd'], default: 'jsd' ) –

    Probability metric to approximate.

  • classifier (Optional[ClassifierProtocol], default: None ) –

    Binary classifier to fit.

polygraph.metrics.standard_pgd.ClassifierClusteringMetric

Bases: ClassifierMetric[Graph]

Classifier metric based on ClusteringHistogram.

Parameters:
  • reference_graphs (Collection[Graph]) –

    Collection of reference networkx graphs.

  • variant (Literal['informedness', 'jsd'], default: 'jsd' ) –

    Probability metric to approximate.

  • classifier (Optional[ClassifierProtocol], default: None ) –

    Binary classifier to fit.

polygraph.metrics.standard_pgd.ClassifierSpectralMetric

Bases: ClassifierMetric[Graph]

Classifier metric based on EigenvalueHistogram.

Parameters:
  • reference_graphs (Collection[Graph]) –

    Collection of reference networkx graphs.

  • variant (Literal['informedness', 'jsd'], default: 'jsd' ) –

    Probability metric to approximate.

  • classifier (Optional[ClassifierProtocol], default: None ) –

    Binary classifier to fit.

polygraph.metrics.standard_pgd.GraphNeuralNetworkClassifierMetric

Bases: ClassifierMetric[Graph]

Classifier metric based on RandomGIN.

Parameters:
  • reference_graphs (Collection[Graph]) –

    Collection of reference networkx graphs.

  • variant (Literal['informedness', 'jsd'], default: 'jsd' ) –

    Probability metric to approximate.

  • classifier (Optional[ClassifierProtocol], default: None ) –

    Binary classifier to fit.