Step Sankey#

Step Sankey Class#

class retentioneering.tooling.step_sankey.step_sankey.StepSankey(eventstream)[source]#

A class for the visualization of user paths in stepwise manner using Sankey diagram.


See also


Call StepSankey tool as an eventstream method.


Find loops and create new synthetic events in the paths of all users having such sequences.


This class provides methods for step matrix calculation and visualization.


See StepSankey user guide for the details.

fit(max_steps=10, threshold=0.05, sorting=None, targets=None)[source]#

Calculate the sankey diagram internal values with the defined parameters. Applying fit method is necessary for the following usage of any visualization or descriptive StepSankey methods.

max_stepsint, default 10

Maximum number of steps in trajectories to include. Should be > 1.

thresholdfloat | int, default 0.05

Used to remove rare events from the plot. An event is collapsed to thresholded_N artificial event if its maximum frequency across all the steps is less than or equal to threshold. The frequency is set with respect to threshold type:

  • If int - the frequency is the number of unique users who had given event at given step.

  • If float - percentage of users: the same as for int, but divided by the number of unique users.

The events which are prohibited for collapsing could be enlisted in target parameter.

sortinglist of str, optional

Define the order of the events visualized at each step. The events that are not represented in the list will follow after the events from the list.

targetsstr or list of str, optional

Contain events that are prohibited for collapsing with threshold parameter.


If max_steps parameter is <= 1.

plot(autosize=True, width=None, height=None)[source]#

Create a Sankey interactive plot based on the calculated values. Should be used after fit().

autosizebool, default True

Plotly autosize parameter. See plotly documentation.

widthint, optional

Plot’s width (in px). See plotly documentation.

heightint, optional

Plot’s height (in px). See plotly documentation.

property params#

Returns the parameters used for the last fitting. Should be used after fit().

property values#

Returns two pd.DataFrames which the Sankey diagram is based on.

Should be used after fit().

tuple[pd.DataFrame, pd.DataFrame]
  1. Contains the nodes of the diagram.

  2. Contains the edges of the diagram.


Eventstream.step_sankey(max_steps=10, threshold=0.05, sorting=None, targets=None, autosize=True, width=None, height=None, show_plot=True)[source]#

Show a Sankey diagram visualizing the user paths in stepwise manner.

show_plotbool, default True

If True, a sankey diagram is shown.

See other parameters’ description



A StepSankey class instance fitted to the given parameters.