build_rog_ontology

build_rog_ontology(
    embeddings,
    initial_threshold=0.55,
    min_threshold=0.35,
    threshold_decay=0.9,
    target_coverage=0.95,
    diversity_gap_threshold=0.02,
    k_neighbors=30,
    max_depth=5,
    verbose=False,
)

Recursive Ontological Generation (ROG).

Recursively builds ontology layers at decreasing similarity thresholds, then knits them together. Achieves higher coverage than single-threshold approaches by adapting to local density.

Algorithm

  1. Build ontology at initial_threshold
  2. Identify outliers (unconnected nodes)
  3. If coverage < target and threshold > min:
    • Recurse on outliers with threshold * decay
  4. Knit all layers with bridge edges
  5. Return unified ontology with layer metadata

Parameters

Name Type Description Default
embeddings np.ndarray Embeddings to analyze (n, d). Will be L2-normalized. required
initial_threshold float Starting similarity threshold (default 0.55). 0.55
min_threshold float Minimum threshold to try (default 0.35). 0.35
threshold_decay float Multiply threshold by this each recursion (default 0.9). 0.9
target_coverage float Stop recursing when this coverage reached (default 0.95). 0.95
diversity_gap_threshold float Minimum diversity gap for edges (default 0.02). 0.02
k_neighbors int Number of neighbors for k-NN graph. 30
max_depth int Maximum recursion depth (default 5). 5
verbose bool Print progress information. False

Returns

Name Type Description
ROGResult ROGResult with unified ontology and layer metadata.

Example

from dyf import build_rog_ontology

result = build_rog_ontology(embeddings, verbose=True) print(result.summary())

Access unified ontology

ontology = result.ontology ancestors = ontology.get_ancestors(node_idx)

Check which layer a node came from

layer = result.get_layer_for_node(node_idx) if layer is not None: … print(f”Node from layer {layer}“)