Agent Analysis
From a completed Result, you can get an explanation of the model's current state and recommendations for the next step. There are three features:
Warning
Agent Analysis output is generated by an AI and can contain mistakes. Review it before making important decisions.
| Feature | Purpose | Method |
|---|---|---|
| Performance Note | An analysis note explaining the model's state | result.get_note() |
| Heatmap Advisor | Recommend heatmap views that surface error bias | result.recommend_heatmaps() |
| AL Strategy Recommender | Recommend an Active Learning collection strategy | result.recommend_al_strategy() |
Prerequisites
- Requires API access and a completed evaluation (
request_evaluation). - Enabled by default. When disabled, calls raise
AgentAnalysisOptedOutError(Enabling/disabling).
Performance Note
Result.get_note() fetches an analysis note (markdown) describing the model's state. It captures, in prose, "where it is strong, where and why it errs, and what improvement helps next" — things aggregate metrics alone don't convey.
note = result.get_note(language="en") # latest completed note (generated and awaited if absent)
note # Jupyter: the note renders as markdown
note.headline # one-line summary
note.show() # terminal: print the full text
print(note.note) # the markdown body (string)
Main parameters
| Argument | Default | Description |
|---|---|---|
language |
None (English) |
Note language (e.g. "ja"). Only applied when freshly generated. |
use_cached |
True |
Reuse the latest completed note if present (cache-first). |
wait |
True |
Block until completion. False returns a NoteHandle immediately. |
timeout |
600.0 |
Max seconds to wait (wait=True). |
# Force regeneration (also use this to switch language)
note = result.get_note(language="ja", use_cached=False)
# Async: trigger only, await later
handle = result.get_note(wait=False)
note = handle.result(timeout=600)
The cache is not scoped by language
A cached note may be in a different language. To be sure you get a given language, pass use_cached=False.
Key AnalysisNote attributes: note (markdown body) / headline (one-line summary).
Integration with get_summary
When a completed note exists, result.get_summary() appends the headline as a single [Analysis Note] line at the end of its output.
Heatmap Advisor (recommended heatmap views)
Result.recommend_heatmaps() picks "which axis pairs to view as a heatmap to reveal where errors concentrate" and returns an analysis note + recommended views (1–N).
advice = result.recommend_heatmaps(language="en") # latest completed result (generated and awaited if absent)
advice # Jupyter: the note renders as markdown
advice.summary() # list of recommended views (title / focus / axes / n_bins / aggregation level)
advice.get_heatmap(0).show() # render the first recommended view
# Fine-tune from a recommendation (explicit values override the recommended ones)
advice.get_heatmap(0, dataset_type="train", n_bins=40).show()
advice.notehas the same shape as a Performance Note (headline/ markdown body).- Rendering options (
mode/cmap, etc.) go on the returnedHeatmap's.show(). use_cached/wait/timeoutwork the same asget_note.
For fetching/rendering/diffing heatmaps themselves, see Heatmap Visualization.
AL Strategy Recommender (collection strategy)
Result.recommend_al_strategy() analyzes internal features and the systematicity of errors and recommends an Active Learning strategy that "beats random for learning". The recommendation feeds straight into heatmap visualization and DataFilter extraction.
rec = result.recommend_al_strategy(
n_data=200, # labeling budget. None uses the recipe default
dataset_type="val", # evaluation split to analyze. None aggregates all GT-bearing splits
# language="ja", # language for param_basis / rationale. English by default
)
print(rec.summary()) # formatted: reason / query_strategy / measured_profile / rationale
print(rec.param_basis) # why this strategy was chosen
# 1) Heatmap visualization with the recommended params
rec.get_heatmap(dataset_type="pool").show()
# 2) DataFilter extraction with the recommended params
ids = data_filter.query(strategy=rec)
# n_data / sampling / aggregation_level are expanded from rec; override explicitly:
ids = data_filter.query(strategy=rec, n_data=500)
# 3) Hand off to a separate extraction script as a strategy file (v0.5.0)
rec.save_query_config("al_strategy.yaml") # .yaml / .yml / .json
ids = data_filter.query(n_data=200, strategy="al_strategy.yaml")
reason (basis of the recommendation)
| reason | Meaning | Effect on query |
|---|---|---|
"ok" |
A measured strategy beat random collection | query_strategy present (recommended) |
"infeasible" |
No measurable difference; a safe default was chosen | query_strategy present |
"low_headroom" |
Little AL headroom (a non-AL action is advised) | No query_strategy; query(strategy=rec) errors |
Key ALRecommendation attributes: reason / query_strategy / n_data / param_basis (why it was chosen) / alternatives (runner-up candidates).
The strategy file holds the extraction method (strategy), the sequence aggregation (sequence, when present) and the values to pass to query() (n_data / aggregation_level / sampling). save_query_config(path, n_data=...) overrides the budget written into the file; rec.to_query_config() returns the same content as a dict.
3D aggregation level
For 3D, rec.aggregation_level may be "sequence". In that case pass a mapping: data_filter.query(strategy=rec, sequence_mapping=...) (or override with aggregation_level="input_id").
Enabling / disabling Agent Analysis
Agent Analysis is enabled by default and controlled by the agent_analysis setting.
mld config set agent_analysis off # disable (global)
mld config set agent_analysis on # enable (global)
mld config set agent_analysis off --profile <name> # per-profile override
- For a temporary switch, use the env var
MLD_AGENT_ANALYSIS=on|off. - Precedence: env var > profile override > global.
When disabled, calling recommend_al_strategy / get_note / recommend_heatmaps raises AgentAnalysisOptedOutError (with a hint to re-enable).
from ml_debugger.util.exception.agent_exception import AgentAnalysisOptedOutError
try:
note = result.get_note()
except AgentAnalysisOptedOutError as e:
print(e.message) # Agent analysis is disabled in your user settings.
print(e.hint) # how to re-enable
For configuring it from the terminal app, see Terminal App (mldebugger).
Related pages
- Heatmap Visualization —
get_heatmap/Heatmap/ deltas - Active Learning — retraining loop using recommendations
- API Reference: Result