Skip to content

Find grains and mappings

Use dependency discovery to evaluate single and bounded-size composite determinants.

dependencies = fw.discover_dependencies(
df, max_key_size=2, max_candidates=100, min_accuracy=0.95,
)
print(dependencies.to_frame("candidates"))
print(dependencies.to_frame("dependencies"))

Candidates report uniqueness, repeated groups and rows, exclusions, and exactly determined features. A unique row identifier may determine every feature; repeated-group support shows whether a candidate also describes recurring entities.

An exact dependency has no target variation within evaluated determinant groups. Approximate dependencies report modal accuracy: one minus the fraction of rows that would need their target changed to the group’s most frequent value. Inspect a finding’s saved exceptions with dependencies.inspect(df, finding_id, exceptions=True). The measurements also contain violating example groups and omitted-group counts.

Add by=["site"] to evaluate conditional dependencies, or missing={...} for sentinels. dropna=True evaluates complete determinant/target rows; false includes missingness as a category. The grain_views collection retains separate compatible populations for sparse keys. Each view has population evidence and a renderable grain; the embedded exact_grain is the selected primary view. Candidate classifications distinguish repeated groupings, unique identifiers, constants and unsupported candidates. Relationships combine only within a compatible population.

Exact grain map from the worked example

For supplied candidates, use fw.grain(df, ["exam", fw.KeySpec("site_exam", ("site", "exam"))]). This is direct evaluation; discovery instead enumerates a bounded candidate space.