Skip to content

Commit 16deea9

Browse files
committed
Updated docs, added PGS5Interval
1 parent 3a1d1a6 commit 16deea9

15 files changed

Lines changed: 365 additions & 29 deletions

File tree

docs/api_reference/metrics/interface.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ We implement the following metrics:
1616
- [VUN](../../metrics/vun.md) - Validity, Uniqueness, Novelty
1717
- [Fréchet Distance](frechet.md) - Optimal transport distance between fitted Gaussians
1818

19-
## Interface Protocols
19+
Metrics that perform uncertainty quantification may return a [`MetricInterval`][polygraph.metrics.base.MetricInterval] object.
20+
21+
22+
## Metric Interface
2023

2124
::: polygraph.metrics.base.GenerationMetric
2225
options:
@@ -34,3 +37,12 @@ We implement the following metrics:
3437
show_full_path: true
3538
show_source: false
3639
heading_level: 3
40+
41+
## Uncertainty Quantification
42+
43+
::: polygraph.metrics.base.MetricInterval
44+
options:
45+
show_root_heading: true
46+
show_full_path: true
47+
show_source: false
48+
heading_level: 3

docs/api_reference/metrics/polygraphscore.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,25 @@
99
heading_level: 2
1010
members: []
1111

12-
## Estimating Distances with a Single Descriptor
12+
## PolyGraphScore
1313

14-
::: polygraph.metrics.base.ClassifierMetric
14+
::: polygraph.metrics.base.PolyGraphScore
15+
options:
16+
show_root_heading: true
17+
show_full_path: true
18+
show_source: false
19+
heading_level: 3
20+
21+
::: polygraph.metrics.base.PolyGraphScoreInterval
1522
options:
1623
show_root_heading: true
1724
show_full_path: true
1825
show_source: false
1926
heading_level: 3
2027

21-
## Combining Descriptors
28+
## Estimating Distances with a Single Descriptor
2229

23-
::: polygraph.metrics.base.PolyGraphScore
30+
::: polygraph.metrics.base.ClassifierMetric
2431
options:
2532
show_root_heading: true
2633
show_full_path: true

docs/datasets/molecules.md

Whitespace-only changes.

docs/metrics/pgs5.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# 5-Descriptor PolyGraphScore
2+
3+
::: polygraph.metrics.polygraphscore
4+
options:
5+
show_root_heading: false
6+
show_full_path: false
7+
show_root_toc_entry: false
8+
show_source: false
9+
heading_level: 2
10+
members: []
11+
12+
13+
## PGS5
14+
15+
::: polygraph.metrics.PGS5
16+
options:
17+
show_root_heading: true
18+
show_full_path: true
19+
show_source: false
20+
heading_level: 3
21+
members: [compute]
22+
23+
::: polygraph.metrics.PGS5Interval
24+
options:
25+
show_root_heading: true
26+
show_full_path: true
27+
show_source: false
28+
heading_level: 3
29+
members: [compute]
30+
31+
32+
## Individual Classifier Metrics
33+
34+
::: polygraph.metrics.polygraphscore.ClassifierOrbitMetric
35+
options:
36+
show_root_heading: true
37+
show_full_path: true
38+
show_source: false
39+
heading_level: 3
40+
41+
::: polygraph.metrics.polygraphscore.ClassifierDegreeMetric
42+
options:
43+
show_root_heading: true
44+
show_full_path: true
45+
show_source: false
46+
heading_level: 3
47+
48+
::: polygraph.metrics.polygraphscore.ClassifierClusteringMetric
49+
options:
50+
show_root_heading: true
51+
show_full_path: true
52+
show_source: false
53+
heading_level: 3
54+
55+
::: polygraph.metrics.polygraphscore.ClassifierSpectralMetric
56+
options:
57+
show_root_heading: true
58+
show_full_path: true
59+
show_source: false
60+
heading_level: 3
61+
62+
::: polygraph.metrics.polygraphscore.GraphNeuralNetworkClassifierMetric
63+
options:
64+
show_root_heading: true
65+
show_full_path: true
66+
show_source: false
67+
heading_level: 3

docs/metrics/vun.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Validity, Uniqueness, Novelty
22

3+
::: polygraph.metrics.vun
4+
options:
5+
show_root_heading: false
6+
show_full_path: false
7+
show_root_toc_entry: false
8+
show_source: false
9+
heading_level: 2
10+
members: []
11+
12+
313
::: polygraph.metrics.VUN
414
options:
515
show_root_heading: true

docs/tutorials/custom_metrics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
## Custom Graph Descriptors
44

5-
## Custom Graph Kernels
5+
## Building MMD Metrics
66

7-
## Building Benchmarks
7+
## Building PolyGraphScore Metrics

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ nav:
2727
- Graph Descriptors: api_reference/utils/graph_descriptors.md
2828
- Graph Kernels: api_reference/utils/graph_kernels.md
2929
- Standardized Metrics:
30+
- PGS5: metrics/pgs5.md
3031
- Gaussian TV MMD: metrics/gaussian_tv_mmd.md
3132
- RBF MMD: metrics/rbf_mmd.md
3233
- VUN: metrics/vun.md
3334
- Datasets:
3435
- Small Synthetic Datasets: datasets/small_synthetic.md
3536
- Procedural Datasets: datasets/procedural.md
3637
- Real-World Datasets: datasets/real_world_topologies.md
37-
- Molecule Datasets: datasets/molecules.md
3838
- Utils:
3939
- Graph Descriptors: utils/descriptors.md
4040
- Graph Kernels: utils/kernels.md

polygraph/metrics/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .base import MetricCollection
2-
from .polygraphscore import PGS5
2+
from .polygraphscore import PGS5, PGS5Interval
33
from .gaussian_tv_mmd import (
44
MMD2CollectionGaussianTV,
55
MMD2IntervalCollectionGaussianTV,
@@ -11,6 +11,7 @@
1111
"VUN",
1212
"MetricCollection",
1313
"PGS5",
14+
"PGS5Interval",
1415
"MMD2CollectionGaussianTV",
1516
"MMD2IntervalCollectionGaussianTV",
1617
"MMD2CollectionRBF",

polygraph/metrics/base/interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
PolyGraph implements metrics that provide either a single estimate or an interval to quantify uncertainty.
3-
While the arguments to these metrics and their return types vary, we provide a minimal common interface here
4-
as the protocol [`GenerationMetric`][polygraph.metrics.base.GenerationMetric].
3+
We provide a minimal common interface for metrics as the protocol [`GenerationMetric`][polygraph.metrics.base.GenerationMetric].
4+
The only requirement to satisfy this interface is to implement a `compute` method that accepts a collection of NetworkX graphs.
55
66
Metrics that implement this interface may be evaluated jointly using the [`MetricCollection`][polygraph.metrics.base.MetricCollection] class.
77

polygraph/metrics/base/metric_interval.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33

44

55
class MetricInterval:
6-
"""Class for representing uncertainty quantifications of a metric."""
6+
"""Class for representing uncertainty quantifications of a metric.
7+
8+
Attributes:
9+
mean: Mean of the metric samples.
10+
std: Standard deviation of the metric samples.
11+
low: Lower bound of the metric interval, if `coverage` is provided.
12+
high: Upper bound of the metric interval, if `coverage` is provided.
13+
coverage: Coverage of the metric interval. If `None`, no bounds are computed, only the mean and standard deviation are set.
14+
"""
715

816
def __init__(
917
self,
@@ -32,6 +40,12 @@ def __init__(
3240
def from_samples(
3341
cls, samples: np.ndarray, coverage: Optional[float] = None
3442
):
43+
"""Create a `MetricInterval` from a collection of samples.
44+
45+
Args:
46+
samples: 1D array of samples.
47+
coverage: Coverage of the interval. If `None`, no bounds are computed, only the mean and standard deviation are set.
48+
"""
3549
if samples.ndim != 1:
3650
raise ValueError("Samples must be a 1D array")
3751

0 commit comments

Comments
 (0)