Compute Distances API

compute_structural_distances(input_parquet, cfg)

D* (Req 7) for every unordered pair of distinct codes.

Rows follow the canonical pair orientation (shallower code first, code order on ties), so each unordered pair appears exactly once. Every value comes from :func:~naics_embedder.utils.naics_hierarchy.tree_distance_matrix, the tree path length through a virtual root above the sectors: no half-step for lineal pairs and no cross-sector constant. No exclusion processing happens here and nothing is written.

Parameters:

Name Type Description Default
input_parquet str

Descriptions parquet with index, level, and code columns.

required
cfg DistancesConfig

Distance configuration (logged for provenance).

required

Returns:

Type Description
DataFrame

DataFrame with idx_i, idx_j, code_i, code_j, structural_distance.