compute_anchor_aligned_encoding_matrix
Compute an oriented cross-encoding matrix for symmetric pairwise GRADIENDs.
This helper is intended for symmetric suites where many binary GRADIENDs cover overlapping feature-class pairs. Rows index an anchor feature class, and signs are aligned so a class is comparable whether it appeared as the left or right class in an individual binary pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pair_by_id
|
Dict[str, Tuple[str, str]]
|
Mapping from trainer/model id to its ordered binary class
pair |
required |
encoder_summary
|
Dict[str, Any]
|
Mapping from trainer/model id to an evaluation result
dict containing an |
required |
feature_classes
|
Sequence[str]
|
Row order and default column order. Must contain at least two classes. |
required |
aggregate
|
str
|
Aggregation applied to aligned contributions. Supported
values are |
'mean'
|
alignment
|
str
|
Column alignment mode. Supported aliases resolve to
|
'factual'
|
column_ids
|
Optional[Sequence[str]]
|
Optional explicit column order/filter. If omitted,
factual/counterfactual alignment uses |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A payload with |
Dict[str, Any]
|
|
Dict[str, Any]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If too few feature classes are passed, |
Source code in gradiend/comparison/anchor_aligned.py
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 382 383 | |