graflo.db.identity_inference¶
Algorithmic identity inference from vertex record samples.
IdentityInferenceConfig
¶
Bases: ConfigBaseModel
External configuration for :class:IdentityInferencer.
Source code in graflo/db/identity_inference.py
IdentityInferenceResult
¶
Bases: ConfigBaseModel
Outcome of identity inference for one vertex type.
Source code in graflo/db/identity_inference.py
IdentityInferencer
¶
Infer vertex identity fields from flat record samples.
Source code in graflo/db/identity_inference.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | |
apply_identity_inference_to_vertices(vertices, samples_by_name, config=None)
¶
Infer and apply identity fields for each vertex type (immutable copy).
Source code in graflo/db/identity_inference.py
bootstrap_is_stable(samples, key_fields, *, n_boots=5, subsample_ratio=0.8, min_sample_size=10, rng=None)
¶
Return whether bootstrap validation passes on every sub-sample.
Source code in graflo/db/identity_inference.py
bootstrap_pass_rate(samples, key_fields, *, n_boots=5, subsample_ratio=0.8, min_sample_size=10, rng=None)
¶
Return the fraction of bootstrap sub-samples that remain fully unique.
Source code in graflo/db/identity_inference.py
column_values(samples, field)
¶
Values of field across samples, missing keys read as None.
eligible_columns(samples, property_names)
¶
Columns usable as key material, with their type costs.
Disqualifies list/bytes columns, long text and mostly-null columns — see
:func:infer_column_type_cost.
Source code in graflo/db/identity_inference.py
greedy_unique_key(samples, ranked_fields)
¶
Grow a key by adding ranked fields until the tuple is unique.
Scores tuples, not columns: a key may be unique while none of its fields is unique alone.
Source code in graflo/db/identity_inference.py
infer_column_type_cost(values)
¶
Return per-column type suitability cost, or None when disqualified.
Source code in graflo/db/identity_inference.py
infer_identities_from_snapshot(snapshot_path, output_path=None, *, config=None)
¶
Infer vertex identities from a GraFlo output snapshot and return an updated copy.
Source code in graflo/db/identity_inference.py
minimize_key_fields(samples, key_fields)
¶
Drop fields from key_fields while the remainder stays fully unique.
Source code in graflo/db/identity_inference.py
prepare_inference_samples(samples, config, rng)
¶
Strip internal fields and optionally subsample to max_sample_size.
Source code in graflo/db/identity_inference.py
score_candidate(fields, type_costs, *, type_cost_weight=0.2, semantic_weight=0.5)
¶
Lower scores are better (parsimony + type cost - semantic bonus).
Source code in graflo/db/identity_inference.py
uniqueness_ratio(samples, key_fields)
¶
Fraction of rows with distinct key tuples.