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=None, height=None, show_weights=None, show_percents=None, show_nodes_names=None, show_all_edges_for_targets=None, show_nodes_without_links=None, show_edge_info_on_hover=None, open_sidebar_by_default=None, nodes_custom_colors=None, edges_custom_colors=None, nodelist=None, layout_dump=None, import_file=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
oruser_id
- the number of unique users.If
event_id
- the number of transitions.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
oruser_id
- the number of unique users.If
event_id
- the number of events.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.
- 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.- 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.
- nodes_custom_colorsdict, optional
Set nodes color explicitly. The dict keys are node names, the values are the corresponding colors. A color can be defined either as an HTML standard color name or a HEX code. See Transition graph user guide for the details.
- edges_custom_colorsdict, optional
Set edges color explicitly. The dict keys are tuples of length 2, e.g. (path_start’, ‘catalog’), the values are the corresponding colors. A color can be defined either as an HTML standard color name or a HEX code. See Transition graph user guide for the details.
- 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.
- open_sidebar_by_defaultbool, default True
This parameter specifies whether the sidebar should be open by default when the interface is loaded. If set to True, the sidebar will be displayed upon initialization, providing users immediate access to its contents. If set to False, the sidebar will remain hidden until the user decides to open it.
- nodelistpd.DataFrame, default None
A DataFrame containing information about nodes, such as weights, parents, etc.
- layout_dumpstr, default None
A string path to a JSON file containing the configuration for nodes layout.
- import_filestr, default None
A string path to a JSON file containing complete dump of a 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=None, height=None, show_weights=None, show_percents=None, show_nodes_names=None, show_all_edges_for_targets=None, show_nodes_without_links=None, show_edge_info_on_hover=None, open_sidebar_by_default=None, nodes_custom_colors=None, edges_custom_colors=None, nodelist=None, layout_dump=None, import_file=None)[source]#
- Parameters:
- See parameters’ description
TransitionGraph.plot()
@TODO: maybe load docs with docrep? 2dpanina, Vladimir Makhanov
- Returns:
- TransitionGraph
Rendered IFrame graph.