.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/11_temporal/plot_39_comparing_systems.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_11_temporal_plot_39_comparing_systems.py: Comparing two versions of a production system ============================================= The suggestions of the HyperGodot case study — drop the redundant final inspection (E7) and automate the manual assembly (E5) — define a redesigned system. The difference hypergraph marks the hyperedges kept, removed and added; group statistics compare human and machine work before and after. .. GENERATED FROM PYTHON SOURCE LINES 12-33 .. code-block:: Python import matplotlib.pyplot as plt import pandas as pd import hatvis as hv from hatvis.plotting import draw_hypergraph before = hv.datasets.load_manufacturing_cps() # [snippet:redesign] after = before.remove_edges(["E7", "E5"]).add_edges({"E5r": ["R3", "C2", "C3", "C4", "FP"]}, weights=[18]) after.edge_data.loc["E5r", ["task", "group"]] = ["Robotic assembly", "M"] diff = hv.temporal.difference(before, after, labels=("before", "after")) stats = pd.concat({"before": hv.temporal.group_statistics(before, weight_name="minutes"), "after": hv.temporal.group_statistics(after, weight_name="minutes")}) # [/snippet:redesign] print(diff.edge_data["status"].value_counts()) print(stats[["hyperedges", "total minutes", "mean size"]]) # [snippet:distance] dist = {kind: hv.similarity.hypergraph_distance(before, after, kind) for kind in ("jaccard", "hamming", "spectral", "degree")} # [/snippet:distance] print({k: round(v, 3) for k, v in dist.items()}) .. rst-class:: sphx-glr-script-out .. code-block:: none status both 5 only before 2 only after 1 Name: count, dtype: int64 hyperedges total minutes mean size before H 5 85.0 3.6 M 2 45.0 4.0 after H 3 40.0 3.333333 M 3 63.0 4.333333 {'jaccard': 0.375, 'hamming': 0.067, 'spectral': 0.094, 'degree': 0.258} .. GENERATED FROM PYTHON SOURCE LINES 34-38 .. code-block:: Python fig, ax = plt.subplots(figsize=(8.5, 6.5)) draw_hypergraph(diff, layout="force", group="status", edge_color="status", ax=ax, random_state=3, edge_labels=True, title="difference: kept (solid), removed and added (dashed, dotted)") plt.tight_layout() .. image-sg:: /auto_examples/11_temporal/images/sphx_glr_plot_39_comparing_systems_001.png :alt: difference: kept (solid), removed and added (dashed, dotted) :srcset: /auto_examples/11_temporal/images/sphx_glr_plot_39_comparing_systems_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.309 seconds) .. _sphx_glr_download_auto_examples_11_temporal_plot_39_comparing_systems.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/hatvis/main?urlpath=lab/tree/notebooks/auto_examples/11_temporal/plot_39_comparing_systems.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_39_comparing_systems.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_39_comparing_systems.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_39_comparing_systems.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_