コンテンツにスキップ

ALRecommendation

Result.recommend_al_strategy が返します。DataFilter.query(strategy=rec) に渡せるほか、save_query_config() で query(strategy=<パス>) が読める戦略ファイルとして保存できます(to_query_config() は同じ内容を辞書で返します)。使い方は Agent Analysis を参照してください。

ml_debugger.result.recommendation.ALRecommendation dataclass

A measured Active-Learning recommendation parsed from the server.

属性:

名前 タイプ デスクリプション
reason str

"ok" (a measured candidate beat random), "infeasible" (could not differentiate), or "low_headroom" (AL is not the most useful next step).

al_recommended bool

False only when reason == "low_headroom".

task_name Optional[str]

"classification" / "object_detection" / "object_detection_3d" / None.

query_strategy Optional[Union[BBoxStrategy, FilterConfig]]

Selection strategy for DataFilter.query. A :class:BBoxStrategy for object detection, a :class:FilterConfig whose target_column holds the recommended rankings for classification. None when the server has no strategy to offer.

n_data Optional[int]

Labeling budget echoed back from the recommendation request. None when the request did not set one, in which case DataFilter.query needs an explicit n_data.

sampling Any

"class_balanced" / dict / None (passed through to query).

aggregation_level str

"input_id" or "sequence" (3D).

sequence_aggregation Optional[SequenceAggregation]

How the inputs of one sequence fold into that sequence's score, as recommended for a sequence-level selection (3D). None when the recommendation selects whole inputs. How many sequences to collect is not part of it: that budget is n_data.

heatmap Dict[str, Any]

Result.get_heatmap params (sanitized for the heatmap API).

reason_detail Optional[str]

Why there is no usable strategy. None when reason == "ok".

param_basis str

Plain-language explanation of why these params.

rationale str

Short plain-language justification.

alternatives Any

Up to a few runner-up candidates (each carries its own query_strategy).

measured_profile Any

vs_random of the chosen candidate (explainability).

raw Dict[str, Any]

The full recommended_params dict (forward-compatible).

summary()

Return a formatted, human-readable summary of the recommendation.

get_heatmap(dataset_type=None, **overrides)

Fetch the recommended heatmap by delegating to Result.get_heatmap.

The recommended view is fetched as recommended: its axes, target, bins, aggregation level and the strategies that go with that level. None axes fall back to the task defaults of Result.get_heatmap. Any keyword override (e.g. n_bins / aggregation_level / input_strategy / sequence_mapping) wins over the recommended value. Render the returned :class:~ml_debugger.visualization.schemas.Heatmap with .show(mode=..., cmap=...) / .to_figure() / .save(path).

引数:

名前 タイプ デスクリプション デフォルト

dataset_type

Optional[str]

Which dataset to visualize. None (default) draws every dataset the result holds, one heatmap each.

None

**overrides

Any

Forwarded to Result.get_heatmap (e.g. n_bins / aggregation_level / input_strategy / sequence_mapping). Rendering options (mode / cmap / ...) belong on the returned Heatmap's .show() / .save(), not here.

{}

save_query_config(path, n_data=None)

Save the recommendation as a query strategy file.

The file holds :meth:to_query_config and is read back by DataFilter.query(strategy=<path>). Its format follows the suffix: .yaml / .yml for YAML, .json for JSON.

引数:

名前 タイプ デスクリプション デフォルト

path

Union[str, Path]

Destination file path.

必須

n_data

Optional[int]

Labeling budget to write into the file. Defaults to the budget the recommendation was requested for (rec.n_data); pass the real budget when the request used a scaled one.

None

戻り値:

タイプ デスクリプション
Path

The path the file was written to.

発生:

タイプ デスクリプション
ValueError

If the recommendation has no strategy to save, n_data is not a positive integer, or the suffix is not .yaml, .yml or .json.

ImportError

If a YAML file is requested and PyYAML is not installed.

例:

>>> path = rec.save_query_config("al_strategy.yaml")
>>> ids = data_filter.query(n_data=200, strategy="al_strategy.yaml")

to_query_config(n_data=None)

Return the recommendation as the content of a query strategy file.

The dict has the layout DataFilter.query(strategy=<path>) reads from a strategy file: strategy (how to rank and pick the data), sequence (only for a sequence-level recommendation: how the inputs of one sequence fold into its score) and query (n_data / aggregation_level / sampling to pass to query() alongside the file). Every value is a plain builtin, so the dict can be written as YAML or JSON as is.

引数:

名前 タイプ デスクリプション デフォルト

n_data

Optional[int]

Labeling budget to write into the query section. Defaults to the budget the recommendation was requested for (rec.n_data); pass the real budget when the request used a scaled one.

None

戻り値:

タイプ デスクリプション
Dict[str, Any]

The strategy file content as a plain dict.

発生:

タイプ デスクリプション
ValueError

If the recommendation has no strategy to save, or n_data is not a positive integer.

例:

>>> config = rec.to_query_config()
>>> config["query"]["n_data"]
200