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='100%', height='60vh', show_weights=True, show_percents=False, show_nodes_names=True, show_all_edges_for_targets=True, show_nodes_without_links=False, show_edge_info_on_hover=True, layout_dump=None)[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
orevent_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
orevent_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 inedges_weight_col
andnodes_weight_col
parameters. Ifsession_col=session_id
exists, it is added by default to this list.- widthstr, int or float, default “100%”
The width of the plot can be specified in the following ways:
In pixels (int or float);
In other CSS units (str). For example, the default value of “100%” means the plot will occupy 100% of the width of the Jupyter Notebook cell.
- heightstr, int or float, default “60vh”
The height of the plot can be specified as follows:
In pixels (int or float);
In other CSS units (str). For example, the default value of “60vh” means the plot will occupy 60% of the height of the browser window.
The resulting height can’t be lower than 600px.
- 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.
- show_edge_info_on_hoverbool, default True
This parameter determines whether information about an edge (weight, source node, target node) is displayed when hovering the mouse over it.
- layout_dumpstr, default None
A string path to the JSON file containing the configuration for node positioning. This parameter enables applying the saved mutual positioning of nodes, exported as JSON, to the graph.
- Returns:
- Rendered IFrame graph.
Notes
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.The thresholds may use their own weighting columns both for nodes and for edges independently of weighting columns defined in
edges_weight_col
andnodes_weight_col
arguments.
See TransitionGraph user guide for the details.
- property recalculation_result#
Export an eventstream after GUI actions that affect eventstream.
- Returns:
- EventstreamType
The modified event stream.
Notes
Renaming groups, nodes, and nested nodes in the GUI will not affect the resulting eventstream. The default group and node names will be returned.
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='100%', height='60vh', show_weights=True, show_percents=False, show_nodes_names=True, show_all_edges_for_targets=True, show_nodes_without_links=False, show_edge_info_on_hover=True, layout_dump=None)[source]#
- Parameters:
- See parameters’ description
TransitionGraph.plot()
@TODO: maybe load docs with docrep? 2dpanina, Vladimir Makhanov
- Returns:
- TransitionGraph
Rendered IFrame graph.