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.

Parameters:
eventstreamEventstreamType

See also

Eventstream.step_sankey

Call StepSankey tool as an eventstream method.

CollapseLoops

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

StepMatrix

This class provides methods for step matrix calculation and visualization.

Notes

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.

Parameters:
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.

Raises:
ValueError

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().

Parameters:
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.

Returns:
plotly.graph_objects.Figure
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().

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

  2. Contains the edges of the diagram.

Eventstream#

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.

Parameters:
show_plotbool, default True

If True, a sankey diagram is shown.

See other parameters’ description

StepSankey

Returns:
StepSankey

A StepSankey class instance fitted to the given parameters.