Skip to content

Commit 6c77734

Browse files
committed
add: add kg_evaluate config file for params
1 parent a44b1f3 commit 6c77734

2 files changed

Lines changed: 34 additions & 17 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
source_text_paths:
2+
- data/protein_source.txt
3+
- data/dna_source.txt
4+
- data/rna_source.txt
5+
6+
structure_thresholds:
7+
noise_ratio: 0.15
8+
largest_cc_ratio: 0.90
9+
avg_degree_min: 2.0
10+
avg_degree_max: 5.0
11+
powerlaw_r2: 0.75
12+

graphgen/models/evaluator/kg/structure_evaluator.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@
2020
class StructureEvaluator:
2121
"""Evaluates structural robustness of the graph."""
2222

23-
# Thresholds for structural metrics
24-
NOISE_RATIO_THRESHOLD = 0.15
25-
LARGEST_CC_RATIO_THRESHOLD = 0.90
26-
AVG_DEGREE_MIN = 2
27-
AVG_DEGREE_MAX = 5
28-
POWERLAW_R2_THRESHOLD = 0.75
29-
30-
def __init__(self, graph_storage: BaseGraphStorage):
23+
def __init__(
24+
self,
25+
graph_storage: BaseGraphStorage,
26+
noise_ratio_threshold: float = 0.15,
27+
largest_cc_ratio_threshold: float = 0.90,
28+
avg_degree_min: float = 2.0,
29+
avg_degree_max: float = 5.0,
30+
powerlaw_r2_threshold: float = 0.75,
31+
):
3132
self.graph_storage = graph_storage
33+
self.noise_ratio_threshold = noise_ratio_threshold
34+
self.largest_cc_ratio_threshold = largest_cc_ratio_threshold
35+
self.avg_degree_min = avg_degree_min
36+
self.avg_degree_max = avg_degree_max
37+
self.powerlaw_r2_threshold = powerlaw_r2_threshold
3238

3339
def evaluate(self) -> Dict[str, Any]:
3440
if nx is None:
@@ -73,27 +79,26 @@ def evaluate(self) -> Dict[str, Any]:
7379
# Power law distribution R²
7480
powerlaw_r2 = self._calculate_powerlaw_r2(G)
7581

76-
# Check thresholds
7782
thresholds = {
7883
"noise_ratio": {
7984
"value": noise_ratio,
80-
"threshold": self.NOISE_RATIO_THRESHOLD,
81-
"pass": noise_ratio < self.NOISE_RATIO_THRESHOLD,
85+
"threshold": self.noise_ratio_threshold,
86+
"pass": noise_ratio < self.noise_ratio_threshold,
8287
},
8388
"largest_cc_ratio": {
8489
"value": largest_cc_ratio,
85-
"threshold": self.LARGEST_CC_RATIO_THRESHOLD,
86-
"pass": largest_cc_ratio > self.LARGEST_CC_RATIO_THRESHOLD,
90+
"threshold": self.largest_cc_ratio_threshold,
91+
"pass": largest_cc_ratio > self.largest_cc_ratio_threshold,
8792
},
8893
"avg_degree": {
8994
"value": avg_degree,
90-
"threshold": (self.AVG_DEGREE_MIN, self.AVG_DEGREE_MAX),
91-
"pass": self.AVG_DEGREE_MIN <= avg_degree <= self.AVG_DEGREE_MAX,
95+
"threshold": (self.avg_degree_min, self.avg_degree_max),
96+
"pass": self.avg_degree_min <= avg_degree <= self.avg_degree_max,
9297
},
9398
"powerlaw_r2": {
9499
"value": powerlaw_r2,
95-
"threshold": self.POWERLAW_R2_THRESHOLD,
96-
"pass": powerlaw_r2 > self.POWERLAW_R2_THRESHOLD if powerlaw_r2 is not None else False,
100+
"threshold": self.powerlaw_r2_threshold,
101+
"pass": powerlaw_r2 > self.powerlaw_r2_threshold if powerlaw_r2 is not None else False,
97102
},
98103
}
99104

0 commit comments

Comments
 (0)