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.
Attributes:
| Name | Type | Description |
|---|---|---|
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Name of the ML model to be evaluated. This identifier is used to organize and track evaluation results. |
required |
|
str
|
Version identifier of the ML model. Allows tracking evaluations across different model versions. |
required |
|
Optional[str]
|
Base API endpoint URL for the evaluation service. If None, uses default service configuration. Defaults to None. |
None
|
|
Optional[str]
|
API key for authentication with the evaluation service. If None, uses default authentication method. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The name of the evaluation method to execute. This corresponds to predefined evaluation algorithms or metrics available in the evaluation service. |
'default'
|
|
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
|
|
Union[str, Optional[int]]
|
n_epoch filter for evaluation |
'latest'
|
|
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
|
|
Optional[str]
|
The single output to evaluate, on a model that produces several. Defaults to None (evaluate every output). |
None
|
Returns:
| Type | Description |
|---|---|
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
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the method_name is not supported, or if |
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Optional[str]
|
Specific result name to filter by. If None, returns all available results. Defaults to None. |
None
|
|
Optional[str]
|
Name of evaluation method to filter.
|
None
|
|
Union[str, Optional[int]]
|
Filter option for n_epoch value.
|
'latest'
|
|
Optional[str]
|
The single output to list, on a model that produces several. Defaults to None (list every output). |
None
|
Returns:
| Type | Description |
|---|---|
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
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. |
required |
|
Union[str, Optional[int]]
|
Filter option for n_epoch value.
|
'latest'
|
|
Optional[str]
|
The single output to retrieve from, on a model that produces several. Defaults to None (retrieve from every output). |
None
|
Returns:
| Type | Description |
|---|---|
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. |
Raises:
| Type | Description |
|---|---|
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])).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Server-side result selector, mirrored verbatim:
|
'latest'
|
|
Optional[str]
|
Concrete method name; required when
|
None
|
|
Optional[str]
|
Substring; required when
|
None
|
|
Optional[str]
|
Target version. |
None
|
|
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
|
Returns:
| Type | Description |
|---|---|
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. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Optional[str]
|
The single output to list the versions of, on a model that produces several. Defaults to None (list every output's). |
None
|
Returns:
| Type | Description |
|---|---|
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. |