reasons¶
Reason-code mapping layer (spec section 8).
Deterministic post-processor from a local decomposition to ranked adverse-action reasons: Group A (derogatory information, driven by the I channel) versus Group B (insufficient information, driven by D + M). The mapping table ships configurable; legally operative wording stays with the lender's compliance function.
ReasonCode
dataclass
¶
ReasonCode(
feature: str,
group: str,
subtype: str,
contribution: float,
text: str,
)
One ranked adverse-action reason.
map_reasons ¶
map_reasons(
instance_channels: DataFrame,
*,
dictionary: Mapping[str, str] | None = None,
orientation: str = "higher_is_better",
k: int = 4,
theta_abs: float = 0.05,
theta_rel: float = 0.5
) -> list[ReasonCode]
Map one instance's channels to ranked, group-tagged reason codes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance_channels
|
DataFrame
|
Frame with columns |
required |
dictionary
|
Mapping[str, str] | None
|
Optional feature -> approved reason text mapping; features not in the dictionary fall back to subtype templates. |
None
|
orientation
|
str
|
|
'higher_is_better'
|
k
|
int
|
Maximum number of reasons emitted. |
4
|
theta_abs
|
float
|
Group B is emitted only when |
0.05
|
theta_rel
|
float
|
Group B is emitted only when |
0.05
|
Source code in src/triadxai/reasons.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |