Transition Graph#

Transition Graph class#

class retentioneering.tooling.transition_graph.transition_graph.TransitionGraph(eventstream)[source]#

A class that holds methods for transition graph visualization.

Parameters:
eventstream: EventstreamType

Source eventstream.

See also

Eventstream.transition_graph

Call TransitionGraph tool as an eventstream method.

Eventstream.transition_matrix

Matrix representation of transition graph.

EventstreamSchema

Schema of eventstream columns, that could be used as weights.

TransitionGraph.plot

Interactive transition graph visualization.

Notes

See transition graph user guide for the details.

plot(targets=None, edges_norm_type=None, nodes_threshold=None, nodes_norm_type=None, edges_threshold=None, nodes_weight_col=None, edges_weight_col=None, custom_weight_cols=None, width=960, height=600, show_weights=True, show_percents=False, show_nodes_names=True, show_all_edges_for_targets=True, show_nodes_without_links=False)[source]#

Create interactive transition graph visualization with callback to sourcing eventstream.

Parameters:
edges_norm_type{“full”, “node”, None}, default None

Type of normalization that is used to calculate weights for graph edges. Based on edges_weight_col parameter the weight values are calculated.

  • If None, normalization is not used, the absolute values are taken.

  • If full, normalization across the whole eventstream.

  • If node, normalization across each node (or outgoing transitions from each node).

See Transition graph user guide for the details.

nodes_norm_type{“full”, “node”, None}, default None

Currently not implemented. Always None.

edges_weight_colstr, optional

A column name from the EventstreamSchema which values will control the final edges’ weights and displayed width as well.

For each edge is calculated:

  • If None or event_id - the number of transitions.

  • If user_id - the number of unique users.

  • If session_id - the number of unique sessions.

  • If custom_col - the number of unique values in selected column.

See Transition graph user guide for the details.

edges_thresholddict, optional

Threshold mapping that defines the minimal weights for edges displayed on the canvas.

  • Keys should be of type str and contain the weight column names (the values from the EventstreamSchema).

  • Values of the dict are the thresholds for the edges that will be displayed.

Support multiple weighting columns. In that case, logical OR will be applied. Edges with value less than at least one of thresholds will be hidden. Example: {‘event_id’: 100, user_id: 50}.

See Transition graph user guide for the details.

nodes_weight_colstr, optional

A column name from the EventstreamSchema which values control the final nodes’ weights and displayed diameter as well.

For each node is calculated:

  • If None or event_id - the number of events.

  • If user_id - the number of unique users.

  • If session_id - the number of unique sessions.

  • If custom_col - the number of unique values in selected column.

See Transition graph user guide for the details.

nodes_thresholddict, optional

Threshold mapping that defines the minimal weights for nodes displayed on the canvas.

  • Keys should be of type str and contain the weight column names (the values from the EventstreamSchema).

  • Values of the dict are the thresholds for the nodes that will be displayed. They should be of type int or float.

Support multiple weighting columns. In that case, logical OR will be applied. Nodes with value less than at least one of thresholds will be hidden. Example: {‘event_id’: 100, user_id: 50}.

See Transition graph user guide for the details.

targetsdict, optional

Events mapping that defines which nodes and edges should be colored for better visualization.

  • Possible keys: “positive” (green), “negative” (red), “source” (orange).

  • Possible values: list of events of a given type.

See Transition graph user guide for the details.

custom_weight_colslist of str, optional

Custom columns from the EventstreamSchema that can be selected in edges_weight_col and nodes_weight_col parameters. If session_col=session_id exists, it is added by default to this list.

widthint, default 960

Width of plot in pixels.

heightint, default 600

Height of plot in pixels.

show_weightsbool, default True

Hide/display the edge weight labels. By default, weights are shown.

show_percentsbool, default False

Display edge weights as percents. Available only if an edge normalization type is chosen. By default, weights are displayed in fractions.

show_nodes_namesbool, default True

Hide/display the node names. By default, names are shown.

show_all_edges_for_targetsbool, default True

This displaying option allows to ignore the threshold filters and always display any edge connected to a target node. By default, all such edges are shown.

show_nodes_without_linksbool, default False

Setting a threshold filter might remove all the edges connected to a node. Such isolated nodes might be considered as useless. This displaying option hides them in the canvas as well.

@TODO: add show_edge_info_on_hover Ticket: https://retentioneering.atlassian.net/browse/PLAT-776. dpanina.
Returns:
Rendered IFrame graph.

Notes

  1. If all the edges connected to a node are hidden, the node becomes hidden as well. In order to avoid it - use show_nodes_without_links=True parameter in code or in the interface.

  2. The thresholds may use their own weighting columns both for nodes and for edges independently of weighting columns defined in edges_weight_col and nodes_weight_col arguments.

See TransitionGraph user guide for the details.

Eventstream#

Eventstream.transition_graph(edges_norm_type=None, nodes_norm_type=None, targets=None, nodes_threshold=None, edges_threshold=None, nodes_weight_col=None, edges_weight_col=None, custom_weight_cols=None, width=960, height=600, show_weights=True, show_percents=False, show_nodes_names=True, show_all_edges_for_targets=True, show_nodes_without_links=False)[source]#
Parameters:
See parameters’ description

TransitionGraph.plot()

Returns:
TransitionGraph

Rendered IFrame graph.