.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/07_applications/plot_02_clickstream_story.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_07_applications_plot_02_clickstream_story.py: Case study: the UWV unemployment-benefit application ==================================================== The clickstream of the paper, read as a story. Where do applicants start, which service sequences are typical, where do they hesitate, and which steps are predictable? .. GENERATED FROM PYTHON SOURCE LINES 9-18 .. code-block:: Python import matplotlib.pyplot as plt import spmviz as sv from spmviz.viz import plot_prediction, plot_prefix_tree, plot_sankey, plot_transition_graph db = sv.datasets.load_clickstream() ps = sv.mine(db, 0.01, algorithm="cmspam", max_gap=1, max_length=10) .. GENERATED FROM PYTHON SOURCE LINES 19-21 The paths of the first steps ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 21-23 .. code-block:: Python plot_sankey(db, max_steps=5, top=6) .. image-sg:: /auto_examples/07_applications/images/sphx_glr_plot_02_clickstream_story_001.png :alt: Sankey diagram of 343 sequences :srcset: /auto_examples/07_applications/images/sphx_glr_plot_02_clickstream_story_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 24-26 The transition graph of the services ------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 26-28 .. code-block:: Python plot_transition_graph(db, top_edges=26, labels=None) .. image-sg:: /auto_examples/07_applications/images/sphx_glr_plot_02_clickstream_story_002.png :alt: transition (directly-follows) graph :srcset: /auto_examples/07_applications/images/sphx_glr_plot_02_clickstream_story_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 29-31 Predictability of the next service ---------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 31-33 .. code-block:: Python plot_prefix_tree(db, max_depth=4, min_count=12, color_by="entropy") .. image-sg:: /auto_examples/07_applications/images/sphx_glr_plot_02_clickstream_story_003.png :alt: plot 02 clickstream story :srcset: /auto_examples/07_applications/images/sphx_glr_plot_02_clickstream_story_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 34-36 What comes next after "Your last employer → The dismissal"? ------------------------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 36-40 .. code-block:: Python obs = [0, 1] # Your last employer, The dismissal print(sv.predict_next(ps, obs)) plot_prediction(ps, obs) plt.show() .. image-sg:: /auto_examples/07_applications/images/sphx_glr_plot_02_clickstream_story_004.png :alt: what comes next? (confidence of the extensions of the longest matching frequent sequence) :srcset: /auto_examples/07_applications/images/sphx_glr_plot_02_clickstream_story_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none next probability support context 0 The dismissal 0.448276 26 Your last employer → The dismissal 1 Hours worked 0.344828 20 Your last employer → The dismissal .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.351 seconds) .. _sphx_glr_download_auto_examples_07_applications_plot_02_clickstream_story.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/spmviz/main?urlpath=lab/tree/notebooks/auto_examples/07_applications/plot_02_clickstream_story.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_clickstream_story.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_clickstream_story.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_clickstream_story.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_