Skip to content

aggregate_node_attributions

aggregate_node_attributions(
    attributions: DataArray,
    labels: object | None = None,
    *,
    method: str = _DEFAULT_METHOD,
    **method_kwargs: object
) -> xr.Dataset

Reduce mapped node attributions with a registered method.

map_node_attributions names a tensor; this call folds it according to method. The dispatcher looks up the name, applies the method's status warnings, calls the registered function, and stores the method name, the parameters actually used, and the kpnn2 version on the result. Adding a method does not change this function.

Parameters:

Name Type Description Default

attributions

DataArray

Output of map_node_attributions, or an array with the same named dims. Required dims depend on the method. The array is read, never modified.

required

labels

1-d array or pandas.Series

Forwarded to the method. Some methods require it.

None

method

str

Registered method name. Default "rauter_mangano_2026", which is not yet implemented and raises Kpnn2Error. See list_aggregation_methods().

_DEFAULT_METHOD

**method_kwargs

object

Forwarded to the method.

{}

Returns:

Type Description
Dataset

The method's per-node result, with attributes method, method_params, and kpnn2_version added here. method_params is a JSON string of the parameters actually used, defaults included; read it with json.loads. Every attribute is a string, so .to_netcdf keeps them. .attrs is dropped by a CSV round-trip. For a table, .to_dataframe().reset_index().

Raises:

Type Description
Kpnn2Error

If attributions is not a DataArray; method is unknown (the message lists callable methods), removed, or not yet implemented; labels or method kwargs are invalid for the selected method; or the DataArray dims do not match that method.

Warns:

Type Description
UserWarning

If method is experimental: results may change.

FutureWarning

If method is deprecated: names the version and the replacement.

See Also

map_node_attributions : Names the node axis of a layer tensor; call that first. list_aggregation_methods : Registry table (name, status, references, versions).

Notes

Captum is not imported here. Method formulas, required dims, and extra kwargs are documented on each method's reference page. The default method is not yet implemented.

Methods

Pass a name as method=. These functions are not imported from kpnn2. list_aggregation_methods returns the same catalog in Python.

Method Status Description
rauter_mangano_2026 recommended Not yet implemented.