malib.utils.metrics module

class malib.utils.metrics.JointDistMetric(agents: List[str])[source]

Bases: malib.utils.metrics.Metric

class Meta[source]

Bases: object

ACTION_DIST = 'action_dist'
REWARD = 'reward'
static merge_parsed(agent_result_seq: Sequence[Dict[str, Any]]) Dict[str, Dict[str, float]][source]

Merge multiple evaluated results.

parse(agent_filter=None) Dict[str, Dict[str, malib.utils.typing.MetricEntry]][source]

Parse episode data, return an agent wise MetricEntry dictionary

reset()[source]
step(agent_id, policy_id, **kwargs)[source]

Record sampled data and save to do evaluation.

class malib.utils.metrics.Metric(agents: List[str])[source]

Bases: object

static merge_parsed(agent_result_seq: Sequence[Dict[str, Any]]) Dict[str, Dict[str, float]][source]

Merge multiple evaluated results.

abstract parse(agent_filter=None) Dict[str, Dict[str, malib.utils.typing.MetricEntry]][source]

Parse episode data and filter with given keys (agent level)

reset(mode='single')[source]
abstract step(agent_id, policy_id, **kwargs) None[source]

Record sampled data and save to do evaluation.

property step_mode: str
class malib.utils.metrics.SimpleMetrics(agents: List[str])[source]

Bases: malib.utils.metrics.Metric

static merge_parsed(agent_result_seq: Sequence) Dict[str, Dict[str, malib.utils.typing.MetricEntry]][source]

Aggregates a sequence of evaluated results in average, and return an agent dict.

parse(agent_filter=None) Dict[str, Dict[str, malib.utils.typing.MetricEntry]][source]

Parse episode data and filter with given keys (agent level)

reset(mode: str = 'single')[source]
step(agent_id, policy_id, **kwargs) None[source]

Record sampled data and save to do evaluation.

malib.utils.metrics.get_metric(metric_type: str)[source]

Return a metric handler with given name.

Parameters

metric_type (str) – Registered metric type.

malib.utils.metrics.to_metric_entry(data: Dict[str, Any], prefix='')[source]

Convert a dict of metrics to a dict or metric entries.

Parameters

data (Dict[str,Any]) – Raw metrics dict.

Returns

A dict of metric entries.