Metrics API
PolyGraph implements metrics that provide either a single estimate or an interval to quantify uncertainty.
We provide a minimal common interface for metrics as the protocol GenerationMetric.
The only requirement to satisfy this interface is to implement a compute method that accepts a collection of graphs.
In practice, these graphs may either be nx.Graph or rdkit.Chem.Mol objects, as determined by the GraphType generic parameter.
Metrics that implement this interface may be evaluated jointly using the MetricCollection class.
from polygraph.metrics import MetricCollection, StandardPGD
from polygraph.metrics.rbf_mmd import RBFOrbitMMD2
from polygraph.datasets import PlanarGraphDataset, SBMGraphDataset
reference_graphs = PlanarGraphDataset("val").to_nx()
generated_graphs = SBMGraphDataset("val").to_nx()
metrics = MetricCollection(
metrics={
"rbf_orbit": RBFOrbitMMD2(reference_graphs=reference_graphs),
"pgd": StandardPGD(reference_graphs=reference_graphs),
}
)
print(metrics.compute(generated_graphs))
We implement the following metrics:
- MMD - Classical Maximum Mean Discrepancy
- PolyGraphDiscrepancy - Lower bounds on probability metrics via classification
- VUN - Validity, Uniqueness, Novelty
- Fréchet Distance - Optimal transport distance between fitted Gaussians
Metrics that perform uncertainty quantification may return a MetricInterval object.
Metric Interface
polygraph.metrics.base.GenerationMetric
Bases: Protocol, Generic[GraphType]
Interface for all graph generation metrics.
compute(generated_graphs)
Compute the metric on the generated graphs.
| Parameters: |
|
|---|
Metric Collections
polygraph.metrics.base.MetricCollection
Bases: GenerationMetric[GraphType], Generic[GraphType]
Collection of metrics that are evaluated jointly.
compute(generated_graphs)
Compute the metrics on the generated graphs.
| Parameters: |
|
|---|
Uncertainty Quantification
polygraph.metrics.base.MetricInterval
Class for representing uncertainty quantifications of a metric.
| Attributes: |
|
|---|
from_samples(samples, coverage=None)
classmethod
Create a MetricInterval from a collection of samples.
| Parameters: |
|
|---|