Output format¶
results.json is a JSON object. By default its keys are Japanese, unchanged since 0.9.
--json-keys en and fxtensor_bayesnet.to_english_keys() write the same tree with
English keys. Names you chose — variable ids, labels, scenario names, intervention names,
effect name values — are never translated.
An observation key that ends with `` を観測`` loses that suffix; any other observation key
is kept. The remark string inside the checks stays Japanese either way.
Snapshots always store the Japanese keys.
Probabilities in the result are rounded to four decimal places, so a distribution may not
sum to exactly 1. JSON null is Python None: a comparison that did not run, or a
conditional probability that is undefined. It is not the number 0.
Top level¶
Japanese |
English |
Contents |
|---|---|---|
|
|
The config’s |
|
|
|
|
|
|
|
|
First 12 hex characters of SHA-256 over the config JSON with sorted keys. |
|
|
|
|
|
One entry per scenario, including the base. See below. |
|
|
One entry per observation, computed under the base priors. Empty object when there are none. |
|
|
Present only when the config has |
|
|
Present only when the config has |
|
|
Present only when the config has |
|
|
Cross-check report. Always present. |
Scenarios¶
The base scenario is stored under 基本 / base. Other keys are the names from the config.
Each value has:
Japanese |
English |
Contents |
|---|---|---|
|
|
The replacement priors for that scenario ( |
|
|
|
Bayesian updates¶
The key is name if the observation has one, otherwise a description plus `` を観測``
(rain=Some を観測, or rain~L[0.2, 0.9] を観測 for soft evidence).
Japanese |
English |
Contents |
|---|---|---|
|
|
Present when the observation is not a single hard label. Soft evidence is |
|
|
Prior probability of hard evidence, rounded to four decimals. Absent when any evidence is soft. |
|
|
Σ P(x) L(x) when any evidence is soft. Not a probability; may exceed 1. Absent for hard-only evidence. |
|
|
|
|
|
|
|
|
Priors of the |
|
|
Movement for focus variables that are not hard evidence. Empty when the observation is impossible. |
|
|
Those variables, largest total variation first. |
Each movement value:
Japanese |
English |
Contents |
|---|---|---|
|
|
Posterior minus prior, in points, one decimal. |
|
|
Total variation, four decimals. |
|
|
KL(posterior || prior) in nats, four decimals. |
Interventions¶
Japanese |
English |
Contents |
|---|---|---|
|
|
|
|
|
Marginals of the output variables under the intervention. |
Effects¶
The key is the string documented in Configuration reference (X → Y=y, with | do(Z) / | W / name).
Japanese |
English |
Contents |
|---|---|---|
|
|
Present only when |
|
|
Treatment variable. |
|
|
Outcome variable. |
|
|
Label y. |
|
|
Treated level. |
|
|
Control level. |
|
|
|
|
|
|
|
|
P(y | do(treated)) − P(y | do(control)). |
|
|
The same contrast under conditioning. |
|
|
Observed difference minus ACE. |
|
|
Treatment levels where the observed conditional is undefined. Absent when there are none. |
|
|
Present when |
|
|
Present when |
Both stratification objects have the same shape:
Japanese |
English |
Contents |
|---|---|---|
|
|
The stratification variable ids, in config order. |
|
|
Map of stratum name ( |
|
|
ACE of the last stratum minus ACE of the first. |
A given_do stratum contains 条件の値 / given_values,
P(結果|do(処置),do(層)) / p_outcome_do_given_do, and ACE / ace.
A given stratum contains 条件の値 / given_values,
P(層|do(処置)) / p_stratum_do,
P(結果|do(処置),層) / p_outcome_do_given (null where the stratum has probability 0 under do(X)),
and ACE / ace (null when either arm is undefined).
Sensitivity¶
The key is target=label.
Japanese |
English |
Contents |
|---|---|---|
|
|
Target variable. |
|
|
Target label. |
|
|
P(target = label) before perturbation. |
|
|
The delta that was used. |
|
|
How many parameters were perturbed, before keeping the top rows. |
|
|
The top rows, largest swing first. |
Each row: パラメータ / parameter (for example priors.cloud → Cloudy or a CPT row),
基準値 / base_value, 下げた値 / low_value, 上げた値 / high_value,
P(下げたとき) / p_low, P(上げたとき) / p_high, and
幅(pt) / swing_pt (two decimal places).
Checks¶
A max-error field is a number only when that comparison ran.
Otherwise it is null. Markdown then says which checks were not run
(未検算 / Not checked), instead of showing a max error of 0.
The fixed remark is
検算はすべて丸め前の値で比較(出力の確率は小数4桁に丸めている)
under 備考 / remark, in Japanese in both key languages.
Displayed max errors use three significant digits.
Japanese |
English |
When it is |
|---|---|---|
|
|
Never. |
|
|
Never. Product of the label counts. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The key is absent when the run had no interventions and no effects. A number when those do() marginals were cross-checked against truncated factorization. |
|
|
Absent unless some observation was skipped. In |
|
|
Absent unless the dense roots × observation tensor would exceed 1,000,000 elements. Those observation keys are listed and the inversion check is skipped. |
|
|
Never null. The Japanese sentence above. |
ancestral mode starts when the joint has more than 2,000,000 elements
(run(..., max_joint=...) can force it in tests).
The wiring-kernel limit for conditioning and for the inversion cross-check is 1,000,000 elements.
>>> from fxtensor_bayesnet import run, to_english_keys
>>> cfg = {
... "as_of": "2026-10-18",
... "variables": {
... "A": {"labels": ["0", "1"]},
... "B": {"labels": ["0", "1"]},
... "C": {"labels": ["0", "1"]},
... },
... "priors": {"A": {"p": [0.6, 0.4]}},
... "kernels": {
... "B": {"parents": ["A"], "cpt": {"0": [0.8, 0.2], "1": [0.3, 0.7]}},
... "C": {"parents": ["B"], "cpt": {"0": [0.9, 0.1], "1": [0.4, 0.6]}},
... },
... "outputs": ["C"],
... }
>>> bare = to_english_keys(run(cfg))["checks"]
>>> bare["max_err_conditioning_vs_einsum"] is None
True
>>> bare["max_err_inversion_vs_conditionalization"] is None
True
>>> "conditioning_check_skipped" in bare
False
>>> isinstance(bare["max_err_joint_vs_einsum"], float)
True
>>> joint = dict(cfg)
>>> joint["observations"] = [{"name": "both", "evidence": {"B": "1", "C": "1"}, "focus": ["A"]}]
>>> skipped = run(joint, max_joint=1)["検算"]
>>> skipped["計算モード"]
'ancestral'
>>> skipped["einsum(全同時)との最大差"] is None
True
>>> skipped["einsum(条件付け)との最大差"] is None
True
>>> skipped["条件付けの検算を省略した観測"]
['both']
>>> en = to_english_keys({"検算": skipped})["checks"]
>>> en["conditioning_check_skipped"]
['both']
>>> en["max_err_conditioning_vs_einsum"] is None
True
>>> one = dict(cfg)
>>> one["observations"] = [{"var": "C", "label": "1", "focus": ["A"]}]
>>> still = run(one, max_joint=1)["検算"]
>>> isinstance(still["einsum(条件付け)との最大差"], float)
True
>>> "条件付けの検算を省略した観測" in still
False
Markdown¶
results.md (and --md) reads the Japanese-key result and prints headings in --lang.
Scenario tables use percentages to one decimal.
The base scenario is labelled 基本 or Base.
Checks are printed as JSON, then a note listing max-error fields that are null
and any observation keys in 条件付けの検算を省略した観測 or
bayesian_inversionの検算を省略した観測.
In English that note uses the English field names.
model.mmd is mermaid. A node id that is not letters, digits, and underscores is replaced
with a short hash so the file stays valid.