shapiq.plot.network#

This module contains the network plots for the shapiq package.

Functions

network_plot([interaction_values, ...])

Draws the interaction network.

shapiq.plot.network.network_plot(interaction_values=None, *, first_order_values=None, second_order_values=None, feature_names=None, feature_image_patches=None, feature_image_patches_size=0.2, center_image=None, center_image_size=0.6, draw_legend=True, center_text=None)[source]#

Draws the interaction network.

An interaction network is a graph where the nodes represent the features and the edges represent the interactions. The edge width is proportional to the interaction value. The color of the edge is red if the interaction value is positive and blue if the interaction value is negative. The interaction values should be derived from the n-Shapley interaction index (n-SII). Below is an example of an interaction network with an image in the center.

../_images/network_example.png
Parameters:
  • interaction_values (Optional[InteractionValues]) – The interaction values as an interaction object.

  • first_order_values (Optional[ndarray[float]]) – The first order n-SII values of shape (n_features,).

  • second_order_values (Optional[ndarray[float]]) – The second order n-SII values of shape (n_features, n_features). The diagonal values are ignored. Only the upper triangular values are used.

  • feature_names (Optional[list[Any]]) – The feature names used for plotting. If no feature names are provided, the feature indices are used instead. Defaults to None.

  • feature_image_patches (Optional[dict[int, Image]]) – A dictionary containing the image patches to be displayed instead of the feature labels in the network. The keys are the feature indices and the values are the feature images. Defaults to None.

  • feature_image_patches_size (Union[float, dict[int, float], None]) – The size of the feature image patches. If a dictionary is provided, the keys are the feature indices and the values are the feature image patch. Defaults to 0.2.

  • center_image (Optional[Image]) – The image to be displayed in the center of the network. Defaults to None.

  • center_image_size (Optional[float]) – The size of the center image. Defaults to 0.6.

  • draw_legend (bool) – Whether to draw the legend. Defaults to True.

  • center_text (Optional[str]) – The text to be displayed in the center of the network. Defaults to None.

Return type:

tuple[Figure, Axes]

Returns:

The figure and the axis containing the plot.