コンテンツにスキップ

Evaluator Class

ml_debugger.evaluator.evaluator.Evaluator

ML Debugger Evaluator for managing model evaluations.

The Evaluator class provides a high-level interface for requesting, managing, and retrieving ML model evaluation results. It handles authentication, evaluation requests, and result management through a service client.

A model that produces several outputs is evaluated one output at a time, and the evaluator is built on the model's own name just the same: it finds the model's outputs and answers with one entry per output, keyed by the output's name. Pass head="..." to work on a single output instead.

属性:

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

Name of the ML model being evaluated.

version_name str

Version identifier of the ML model.

service_client ServiceClient

Client for interacting with the evaluation service.

heads List[str]

Names of this model's outputs, empty for a model with one.

Example
>>> from ml_debugger.evaluator.evaluator import Evaluator
>>> evaluator = Evaluator(
...     model_name="my_model",
...     version_name="v1.0",
...     api_endpoint="https://api.example.com",
...     api_key="your_api_key"
... )
>>> result = evaluator.request_evaluation("ObjectDetection_v1")
>>> results = evaluator.list_results()
>>>
>>> # Retrieve a specific result
>>> retrieved_result = evaluator.get_result(results["result_name"][0])
>>>
>>> # A model with several outputs: one evaluator, a result per output
>>> multi = Evaluator(model_name="my_multi_output_model", version_name="v1.0")
>>> multi.heads
['coarse', 'fine']
>>> results = multi.request_evaluation()
>>> results["coarse"].metrics_summary()
>>> coarse = multi.request_evaluation(head="coarse")

__init__(model_name, version_name, api_endpoint=None, api_key=None)

Initialize the Evaluator instance.

引数:

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

model_name

str

Name of the ML model to be evaluated. This identifier is used to organize and track evaluation results.

必須

version_name

str

Version identifier of the ML model. Allows tracking evaluations across different model versions.

必須

api_endpoint

Optional[str]

Base API endpoint URL for the evaluation service. If None, uses default service configuration. Defaults to None.

None

api_key

Optional[str]

API key for authentication with the evaluation service. If None, uses default authentication method. Defaults to None.

None

発生:

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

If the license validation fails.

ConnectionError

If unable to connect to the evaluation service.

request_evaluation(method_name='default', result_name=None, n_epoch='latest', options=None, *, head=None)

Request a new model evaluation.

Initiates an evaluation request for the specified method and returns a Result object for tracking and retrieving the evaluation outcome.

On a model that produces several outputs, every output is evaluated -- each one against the data recorded for it, and by the evaluation its own task calls for -- and the results come back keyed by output name. Name one output with head to evaluate that one alone.

引数:

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

method_name

str

The name of the evaluation method to execute. This corresponds to predefined evaluation algorithms or metrics available in the evaluation service.

'default'

result_name

Optional[str]

Custom name for the evaluation result. If None, a default name will be generated based on the method and timestamp. Defaults to None.

None

n_epoch

Union[str, Optional[int]]

n_epoch filter for evaluation

'latest'

options

Optional[Dict[str, Any]]

Additional parameters and configuration options for the evaluation method. The structure depends on the specific evaluation method. Defaults to None.

None

head

Optional[str]

The single output to evaluate, on a model that produces several. Defaults to None (evaluate every output).

None

戻り値:

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

Union[Result, Dict[str, Result]]: A Result object that can be used to monitor evaluation progress and retrieve results when completed. On a model with several outputs, one Result per output keyed by output name -- unless head named one, which gives that output's Result on its own.

発生:

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

If the method_name is not supported, or if head names an output this model does not have.

ConnectionError

If unable to communicate with the evaluation service.

Example
>>> result = evaluator.request_evaluation(
...     method_name="ObjectDetection_v1",
...     result_name="model_v1_detection_evaluation",
...     options=None
... )

list_results(result_name=None, method_name=None, n_epoch='latest', *, head=None)

Get list of past evaluation results.

Retrieves a list of evaluation results that have been previously executed. Results can be filtered by name and returned in different formats.

On a model that produces several outputs, each output has evaluations of its own, so the listing comes back keyed by output name. Name one output with head to list that one alone.

引数:

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

result_name

Optional[str]

Specific result name to filter by. If None, returns all available results. Defaults to None.

None

method_name

Optional[str]

Name of evaluation method to filter. default alias available.

None

n_epoch

Union[str, Optional[int]]

Filter option for n_epoch value. latest or all alias available.

'latest'

head

Optional[str]

The single output to list, on a model that produces several. Defaults to None (list every output).

None

戻り値:

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

Union[pd.DataFrame, Dict[str, pd.DataFrame]]: Evaluation results; one frame per output, keyed by output name, on a model with several outputs.

Example
>>> # Get results
>>> results_df = evaluator.list_results()

get_result(result_name, n_epoch='latest', *, head=None)

Get a specific evaluation result.

Retrieves a previously executed evaluation result by name and returns a Result object for accessing the evaluation data and metadata.

On a model that produces several outputs, the name is looked up under every output -- which is how an evaluation requested for the whole model, under a name you chose, is read back -- and the results come back keyed by output name. Name one output with head to retrieve that one alone.

引数:

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

result_name

str

The name of the existing evaluation result to retrieve. This must correspond to a result that was previously created through request_evaluation or is available in the evaluation service.

必須

n_epoch

Union[str, Optional[int]]

Filter option for n_epoch value. latest or all alias available.

'latest'

head

Optional[str]

The single output to retrieve from, on a model that produces several. Defaults to None (retrieve from every output).

None

戻り値:

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

Union[Result, Dict[str, Result]]: A Result object containing the evaluation data and providing methods to access the evaluation outcomes, metrics, and metadata. On a model with several outputs, one Result per output keyed by output name.

発生:

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

If the result_name is not found in the cached results.

ConnectionError

If unable to communicate with the evaluation service.

Example
>>> # First create an evaluation
>>> result = evaluator.request_evaluation(
...     method_name="ObjectDetection_v1",
...     result_name="model_v1_detection_evaluation",
...     options=None
... )
>>>
>>> # Later retrieve the same result
>>> retrieved_result = evaluator.get_result("model_v1_detection_evaluation")
>>> retrieved_result.get_summary()

get_result_series(select_by='latest', method_name=None, result_name=None, version_name=None, *, head=None)

Fetch a time-series of evaluation results for a version (one per epoch).

Calls the server's metrics time-series endpoint once and wraps the response in a :class:~ml_debugger.result.series.ResultSeries, from which per-epoch metrics / issues / heatmaps can be inspected and plotted (and compared across versions via s_a - s_b or s_a.plot_metrics(overlay=[s_b])).

引数:

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

select_by

str

Server-side result selector, mirrored verbatim: "latest" (default), "method_name" (exact match — the "default" alias is NOT expanded here, so pass the concrete server method name), or "result_name" (partial, case-sensitive substring match).

'latest'

method_name

Optional[str]

Concrete method name; required when select_by="method_name".

None

result_name

Optional[str]

Substring; required when select_by="result_name".

None

version_name

Optional[str]

Target version. None (or the bound version) uses this evaluator's authenticated version; any other name selects another version of the same model.

None

head

Optional[str]

The single output to read the series of, on a model that produces several. Defaults to None (read every output's series).

None

戻り値:

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

Union[ResultSeries, Dict[str, ResultSeries]]: The per-epoch result series; one series per output, keyed by output name, on a model with several outputs. Each series covers one output on its own: series are compared across versions of the same output, not across outputs.

発生:

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

version_name does not exist for this model, or head names an output this model does not have.

list_versions(*, head=None)

List the versions of this evaluator's model.

On a model that produces several outputs, each output is versioned on its own, so the listing comes back keyed by output name. Name one output with head to list that one alone.

引数:

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

head

Optional[str]

The single output to list the versions of, on a model that produces several. Defaults to None (list every output's).

None

戻り値:

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

Union[pd.DataFrame, Dict[str, pd.DataFrame]]: One row per version (id, model_id, version_name, model_name, task_name, ...); one frame per output, keyed by output name, on a model with several outputs.