{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "1fBtzpkhbCjc"
   },
   "source": [
    "## Prerequisites\n",
    "\n",
    "Run this cell to prepare the environment. This step is obligatory."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install retentioneering"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "gaOtTZvLbLsw"
   },
   "source": [
    "# Preprocessing"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "WgvQI7AGbO3Z"
   },
   "source": [
    "The full text of [Preprocessing graph](https://doc.retentioneering.com/stable/doc/user_guides/preprocessing.html) user guide is available on the retentioneering website."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "id": "01M2kmcXmBhk"
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from retentioneering import datasets\n",
    "\n",
    "stream = datasets.load_simple_shop()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "nU5gm9OZyWFZ"
   },
   "source": [
    "## Preprocessing GUI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div id=\"a7f0f9d4-f813-410e-ac7b-8c95bde9d36b\">\n",
       "</div>\n",
       "<script>\n",
       "  // We render our widgets inside of iframes (to isolate javascript).\n",
       "  // The @jupyterlab/services library we use reads the basic URL parameters\n",
       "  // for the Jupyter Kernel Gateway and ws connections) from the DOM.\n",
       "  // These parameters are not present in the nested iframe.\n",
       "  // This function copies this configuration to the DOM of the current\n",
       "  // iframe so that PageConfig (https://github.com/jupyterlab/jupyterlab/blob/master/packages/coreutils/src/pageconfig.ts#L36) can retrieve them\n",
       "  function proxyNotebookEnv({ win, doc }) {\n",
       "    const topWindow = window.top\n",
       "\n",
       "    // For classic notebook\n",
       "    try {\n",
       "      const topBody = topWindow.document.body\n",
       "\n",
       "      for (const [name, val] of Object.entries(topBody.dataset)) {\n",
       "        doc.body.dataset[name] = val\n",
       "      }\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "\n",
       "    // Ror Jupyter lab\n",
       "    try {\n",
       "      if (doc.getElementById('jupyter-config-data')) {\n",
       "        return\n",
       "      }\n",
       "      const el = topWindow.document.getElementById('jupyter-config-data')\n",
       "\n",
       "      if (!el) {\n",
       "        return\n",
       "      }\n",
       "\n",
       "      const configData = el.textContent\n",
       "      const id = el.getAttribute('id')\n",
       "      const type = el.getAttribute('type')\n",
       "\n",
       "      const config = doc.createElement('script')\n",
       "      if (id) {\n",
       "        config.setAttribute('id', id)\n",
       "      }\n",
       "      if (type) {\n",
       "        config.setAttribute('type', type)\n",
       "      }\n",
       "      config.textContent = configData\n",
       "      doc.body.appendChild(config)\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function createDoctype({ doc }) {\n",
       "    const newDoctype = doc.implementation.createDocumentType('html', '', '')\n",
       "\n",
       "    if (!doc.doctype) {\n",
       "      doc.insertBefore(newDoctype, doc.childNodes[0])\n",
       "    }\n",
       "  }\n",
       "</script>\n",
       "<script>\n",
       "  (function () {\n",
       "    const width = Number(\"960\") // 960\n",
       "    const height = Number(\"600\") // 900\n",
       "\n",
       "    const iframe = document.createElement(\"iframe\")\n",
       "    iframe.src = \"about:blank\"\n",
       "    iframe.width = width\n",
       "    iframe.height = height\n",
       "\n",
       "    const renderBlock = document.getElementById(\"a7f0f9d4-f813-410e-ac7b-8c95bde9d36b\")\n",
       "\n",
       "    const init = () => {\n",
       "      iframe.contentWindow.__SERVER_ID__ = \"8debc136-fc3b-4e31-a619-8361515af5b7\"\n",
       "      iframe.contentWindow.__ENV__ = \"classic\"\n",
       "      iframe.contentWindow.__WIDTH__ = width\n",
       "      iframe.contentWindow.__HEIGHT__ = height\n",
       "\n",
       "      \n",
       "      iframe.contentWindow.__KERNEL_ID__ = \"12d03262-e638-4c59-b238-023944106232\"\n",
       "      \n",
       "      \n",
       "      iframe.contentWindow.__TRACKING_HARDWARE_ID__ = \"fdaa9a9e-9fe1-4593-b94c-0099fabe092e\"\n",
       "      \n",
       "\n",
       "      const fDocument = iframe.contentDocument\n",
       "      const fWindow = iframe.contentWindow\n",
       "\n",
       "      createDoctype({ doc: fDocument })\n",
       "      proxyNotebookEnv({ win: fWindow, doc: fDocument })\n",
       "\n",
       "      const container = fDocument.createElement(\"div\")\n",
       "      container.id = \"root\"\n",
       "\n",
       "      const script = fDocument.createElement(\"script\")\n",
       "      script.src = \"https://static.server.retentioneering.com/package/@rete/preprocessing-graph/version/1/dist/preprocessing-graph.umd.js?block=a7f0f9d4-f813-410e-ac7b-8c95bde9d36b\"\n",
       "      script.type = \"text/javascript\"\n",
       "\n",
       "      const link = fDocument.createElement(\"link\")\n",
       "      link.rel = \"stylesheet\"\n",
       "      link.href = \"https://static.server.retentioneering.com/package/@rete/preprocessing-graph/version/1/dist/style.css?block=a7f0f9d4-f813-410e-ac7b-8c95bde9d36b\"\n",
       "\n",
       "      const font1 = fDocument.createElement(\"link\")\n",
       "      font1.rel = \"stylesheet\"\n",
       "      font1.href = \"https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap\"\n",
       "\n",
       "      const font2 = fDocument.createElement(\"link\")\n",
       "      font2.rel = \"stylesheet\"\n",
       "      font2.href = \"https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@300;400&display=swap\"\n",
       "\n",
       "      fDocument.body.appendChild(container)\n",
       "      fDocument.body.appendChild(script)\n",
       "      fDocument.body.appendChild(link)\n",
       "      fDocument.body.appendChild(font1)\n",
       "      fDocument.body.appendChild(font2)\n",
       "    }\n",
       "\n",
       "    iframe.onload = () => {\n",
       "      init()\n",
       "    }\n",
       "\n",
       "    renderBlock.appendChild(iframe)\n",
       "  })()\n",
       "</script>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pgraph = stream.preprocessing_graph()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "id": "gXQmtFZdGj-8"
   },
   "outputs": [],
   "source": [
    "def group_products(df, schema):\n",
    "    return df[schema.event_name].isin(['product1', 'product2'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "id": "HmEonwicHHTW"
   },
   "outputs": [],
   "source": [
    "def get_new_users(df, schema):\n",
    "    new_users = df[df[schema.event_name] == 'new_user']\\\n",
    "        [schema.user_id]\\\n",
    "        .unique()\n",
    "    return df[schema.user_id].isin(new_users)\n",
    "\n",
    "def get_existing_users(df, schema):\n",
    "    existing_users = df[df[schema.event_name] == 'existing_user']\\\n",
    "        [schema.user_id]\\\n",
    "        .unique()\n",
    "    return df[schema.user_id].isin(existing_users)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "id": "PMEB_Py1HZ3I"
   },
   "outputs": [],
   "source": [
    "def remove_truncated_paths(df, schema):\n",
    "    truncated_users = df[df[schema.event_name].isin(['cropped_left', 'cropped_right'])]\\\n",
    "        [schema.user_id]\\\n",
    "        .unique()\n",
    "    return ~df[schema.user_id].isin(truncated_users)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 423
    },
    "executionInfo": {
     "elapsed": 233,
     "status": "ok",
     "timestamp": 1682610476218,
     "user": {
      "displayName": "Julia Ostanina",
      "userId": "13687663492290466770"
     },
     "user_tz": -120
    },
    "id": "6yWA_SWmIUBZ",
    "outputId": "5a0a60ce-640b-4cbf-da3a-41a83a20e1a0"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>event_id</th>\n",
       "      <th>event_type</th>\n",
       "      <th>event_index</th>\n",
       "      <th>event</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>user_id</th>\n",
       "      <th>session_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ca9cc3ed-5085-4a60-bb8e-038740cb8d6e</td>\n",
       "      <td>path_start</td>\n",
       "      <td>0</td>\n",
       "      <td>path_start</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>f4b7bcee-65f1-4cbf-b658-179a2e37266e</td>\n",
       "      <td>existing_user</td>\n",
       "      <td>0</td>\n",
       "      <td>existing_user</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>da1231c6-e117-4e43-9e21-0af016cd1fbe</td>\n",
       "      <td>session_start</td>\n",
       "      <td>0</td>\n",
       "      <td>session_start</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>bb732172-8b25-4204-94e7-af80418abca5</td>\n",
       "      <td>raw</td>\n",
       "      <td>0</td>\n",
       "      <td>catalog</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>dd4b2d2c-816d-4a08-a555-11b6a7cb6f12</td>\n",
       "      <td>group_alias</td>\n",
       "      <td>1</td>\n",
       "      <td>product</td>\n",
       "      <td>2019-11-01 17:59:28.459271</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56402</th>\n",
       "      <td>18992bc9-a756-4457-b4d9-fba17840b99b</td>\n",
       "      <td>raw</td>\n",
       "      <td>32280</td>\n",
       "      <td>catalog</td>\n",
       "      <td>2020-04-29 12:48:01.809577</td>\n",
       "      <td>501098384.0</td>\n",
       "      <td>501098384.0_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56403</th>\n",
       "      <td>71bcf87f-f69c-421c-92a2-0b24e4ed9268</td>\n",
       "      <td>raw</td>\n",
       "      <td>32281</td>\n",
       "      <td>main</td>\n",
       "      <td>2020-04-29 12:48:01.938488</td>\n",
       "      <td>501098384.0</td>\n",
       "      <td>501098384.0_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56404</th>\n",
       "      <td>2805ba82-ba52-4cce-a23b-e86f9a8d9d86</td>\n",
       "      <td>raw</td>\n",
       "      <td>32282</td>\n",
       "      <td>catalog</td>\n",
       "      <td>2020-04-29 12:48:06.595390</td>\n",
       "      <td>501098384.0</td>\n",
       "      <td>501098384.0_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56405</th>\n",
       "      <td>403258be-3bb5-405d-bdc3-c2f69c25e56d</td>\n",
       "      <td>session_end</td>\n",
       "      <td>32282</td>\n",
       "      <td>session_end</td>\n",
       "      <td>2020-04-29 12:48:06.595390</td>\n",
       "      <td>501098384.0</td>\n",
       "      <td>501098384.0_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56406</th>\n",
       "      <td>51fd4cdc-eeb4-481d-8d20-3770ebba03aa</td>\n",
       "      <td>path_end</td>\n",
       "      <td>32282</td>\n",
       "      <td>path_end</td>\n",
       "      <td>2020-04-29 12:48:06.595390</td>\n",
       "      <td>501098384.0</td>\n",
       "      <td>501098384.0_6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>56407 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   event_id     event_type  event_index  \\\n",
       "0      ca9cc3ed-5085-4a60-bb8e-038740cb8d6e     path_start            0   \n",
       "1      f4b7bcee-65f1-4cbf-b658-179a2e37266e  existing_user            0   \n",
       "2      da1231c6-e117-4e43-9e21-0af016cd1fbe  session_start            0   \n",
       "3      bb732172-8b25-4204-94e7-af80418abca5            raw            0   \n",
       "4      dd4b2d2c-816d-4a08-a555-11b6a7cb6f12    group_alias            1   \n",
       "...                                     ...            ...          ...   \n",
       "56402  18992bc9-a756-4457-b4d9-fba17840b99b            raw        32280   \n",
       "56403  71bcf87f-f69c-421c-92a2-0b24e4ed9268            raw        32281   \n",
       "56404  2805ba82-ba52-4cce-a23b-e86f9a8d9d86            raw        32282   \n",
       "56405  403258be-3bb5-405d-bdc3-c2f69c25e56d    session_end        32282   \n",
       "56406  51fd4cdc-eeb4-481d-8d20-3770ebba03aa       path_end        32282   \n",
       "\n",
       "               event                  timestamp      user_id     session_id  \n",
       "0         path_start 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "1      existing_user 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "2      session_start 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "3            catalog 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "4            product 2019-11-01 17:59:28.459271  219483890.0  219483890.0_1  \n",
       "...              ...                        ...          ...            ...  \n",
       "56402        catalog 2020-04-29 12:48:01.809577  501098384.0  501098384.0_6  \n",
       "56403           main 2020-04-29 12:48:01.938488  501098384.0  501098384.0_6  \n",
       "56404        catalog 2020-04-29 12:48:06.595390  501098384.0  501098384.0_6  \n",
       "56405    session_end 2020-04-29 12:48:06.595390  501098384.0  501098384.0_6  \n",
       "56406       path_end 2020-04-29 12:48:06.595390  501098384.0  501098384.0_6  \n",
       "\n",
       "[56407 rows x 7 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# press 'Combine'/'Save & Combine' button in GUI before running this cell\n",
    "pgraph.combine_result.to_dataframe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "tPnzp04Wtj1h"
   },
   "source": [
    "## Code-generated preprocessing graph\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "id": "ZFP_E3vBnsMA"
   },
   "outputs": [],
   "source": [
    "from retentioneering.preprocessing_graph import PreprocessingGraph\n",
    "\n",
    "pgraph = PreprocessingGraph(stream)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "2pUaMVnGuLew"
   },
   "source": [
    "### Creating a single node"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "id": "zImapuA3bHA0"
   },
   "outputs": [],
   "source": [
    "from retentioneering.preprocessing_graph import EventsNode\n",
    "from retentioneering.data_processors_lib import GroupEvents, GroupEventsParams\n",
    "\n",
    "def group_products(df, schema):\n",
    "    return df[schema.event_name].isin(['product1', 'product2'])\n",
    "\n",
    "group_events_params = {\n",
    "    \"event_name\": \"product\",\n",
    "    \"func\": group_products\n",
    "}\n",
    "\n",
    "data_processor_params = GroupEventsParams(**group_events_params)\n",
    "data_processor = GroupEvents(params=data_processor_params)\n",
    "node2 = EventsNode(data_processor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "id": "jtko6iebTvTM"
   },
   "outputs": [],
   "source": [
    "node2 = EventsNode(GroupEvents(params=GroupEventsParams(**group_events_params)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "id": "5YA97SSQXqZp"
   },
   "outputs": [],
   "source": [
    "from retentioneering.data_processors_lib import AddStartEndEvents, AddStartEndEventsParams\n",
    "\n",
    "node1 = EventsNode(AddStartEndEvents(params=AddStartEndEventsParams()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Linking nodes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "id": "i9xprcHxT8Aj"
   },
   "outputs": [],
   "source": [
    "pgraph.add_node(node=node1, parents=[pgraph.root])\n",
    "pgraph.add_node(node=node2, parents=[node1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "j5z5__VjZ2Bp"
   },
   "source": [
    "### Building the whole graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "id": "5GPmlBdaZyHf"
   },
   "outputs": [],
   "source": [
    "from retentioneering.data_processors_lib import LabelNewUsers, LabelNewUsersParams\n",
    "\n",
    "google_spreadsheet_id = '1iggpIT5CZcLILLZ94wCZPQv90tERwi1IB5Y1969C8zc'\n",
    "link = f'https://docs.google.com/spreadsheets/u/1/d/{google_spreadsheet_id}/export?format=csv&id={google_spreadsheet_id}'\n",
    "new_users = pd.read_csv(link, header=None)[0].tolist()\n",
    "node3 = EventsNode(LabelNewUsers(params=LabelNewUsersParams(new_users_list=new_users)))\n",
    "pgraph.add_node(node=node3, parents=[node2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "id": "h3q8inbaTurN"
   },
   "outputs": [],
   "source": [
    "from retentioneering.data_processors_lib import FilterEvents, FilterEventsParams\n",
    "\n",
    "def get_new_users(df, schema):\n",
    "    new_users = df[df[schema.event_name] == 'new_user']\\\n",
    "        [schema.user_id]\\\n",
    "        .unique()\n",
    "    return df[schema.user_id].isin(new_users)\n",
    "\n",
    "def get_existing_users(df, schema):\n",
    "    existing_users = df[df[schema.event_name] == 'existing_user']\\\n",
    "        [schema.user_id]\\\n",
    "        .unique()\n",
    "    return df[schema.user_id].isin(existing_users)\n",
    "\n",
    "\n",
    "node4 = EventsNode(FilterEvents(params=FilterEventsParams(func=get_new_users)))\n",
    "node5 = EventsNode(FilterEvents(params=FilterEventsParams(func=get_existing_users)))\n",
    "pgraph.add_node(node=node4, parents=[node3])\n",
    "pgraph.add_node(node=node5, parents=[node3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "id": "5CFDNCo3eUv3"
   },
   "outputs": [],
   "source": [
    "from retentioneering.data_processors_lib import LabelCroppedPaths, LabelCroppedPathsParams\n",
    "\n",
    "params = {\n",
    "    \"left_cutoff\": (1, 'h'),\n",
    "    \"right_cutoff\": (1, 'h'),\n",
    "}\n",
    "node6 = EventsNode(LabelCroppedPaths(params=LabelCroppedPathsParams(**params)))\n",
    "pgraph.add_node(node=node6, parents=[node5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "id": "ZAHfra7hfEKZ"
   },
   "outputs": [],
   "source": [
    "def remove_truncated_paths(df, schema):\n",
    "    truncated_users = df[df[schema.event_name].isin(['cropped_left', 'cropped_right'])]\\\n",
    "        [schema.user_id]\\\n",
    "        .unique()\n",
    "    return ~df[schema.user_id].isin(truncated_users)\n",
    "\n",
    "node7 = EventsNode(FilterEvents(params=FilterEventsParams(func=remove_truncated_paths)))\n",
    "pgraph.add_node(node=node7, parents=[node6])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "id": "8IPCIwn6fNwa"
   },
   "outputs": [],
   "source": [
    "from retentioneering.preprocessing_graph import MergeNode\n",
    "\n",
    "node8 = MergeNode()\n",
    "pgraph.add_node(node=node8, parents=[node4, node7])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "id": "3gp2ClQZfvB6"
   },
   "outputs": [],
   "source": [
    "from retentioneering.data_processors_lib import SplitSessions, SplitSessionsParams\n",
    "\n",
    "node9 = EventsNode(SplitSessions(params=SplitSessionsParams(timeout=(30, 'm'))))\n",
    "pgraph.add_node(node=node9, parents=[node8])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "NnuX-N8VgI70"
   },
   "source": [
    "### Running the calculation\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 608
    },
    "executionInfo": {
     "elapsed": 12697,
     "status": "ok",
     "timestamp": 1682611683371,
     "user": {
      "displayName": "Julia Ostanina",
      "userId": "13687663492290466770"
     },
     "user_tz": -120
    },
    "id": "y508oKhMgHmQ",
    "outputId": "049fb227-981a-40b2-b4b2-842fa9a4b4f1",
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>event_id</th>\n",
       "      <th>event_type</th>\n",
       "      <th>event_index</th>\n",
       "      <th>event</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>user_id</th>\n",
       "      <th>session_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5f3c4b0d-36d5-47b5-8f2d-332aa6e206d8</td>\n",
       "      <td>path_start</td>\n",
       "      <td>0</td>\n",
       "      <td>path_start</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>814840bf-27a3-45b4-bd18-10358a48fa1f</td>\n",
       "      <td>existing_user</td>\n",
       "      <td>0</td>\n",
       "      <td>existing_user</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5190b07d-238b-4907-866b-ee7811757f7d</td>\n",
       "      <td>session_start</td>\n",
       "      <td>0</td>\n",
       "      <td>session_start</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>c0f910d4-c2c9-4baf-8300-19a74f7a2b0d</td>\n",
       "      <td>raw</td>\n",
       "      <td>0</td>\n",
       "      <td>catalog</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7933f7d8-fca4-4ed8-b7f3-5436b13e3ca1</td>\n",
       "      <td>group_alias</td>\n",
       "      <td>1</td>\n",
       "      <td>product</td>\n",
       "      <td>2019-11-01 17:59:28.459271</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               event_id     event_type  event_index  \\\n",
       "0  5f3c4b0d-36d5-47b5-8f2d-332aa6e206d8     path_start            0   \n",
       "1  814840bf-27a3-45b4-bd18-10358a48fa1f  existing_user            0   \n",
       "2  5190b07d-238b-4907-866b-ee7811757f7d  session_start            0   \n",
       "3  c0f910d4-c2c9-4baf-8300-19a74f7a2b0d            raw            0   \n",
       "4  7933f7d8-fca4-4ed8-b7f3-5436b13e3ca1    group_alias            1   \n",
       "\n",
       "           event                  timestamp      user_id     session_id  \n",
       "0     path_start 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "1  existing_user 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "2  session_start 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "3        catalog 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "4        product 2019-11-01 17:59:28.459271  219483890.0  219483890.0_1  "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "processed_stream = pgraph.combine(node=node9)\n",
    "processed_stream.to_dataframe().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "ULU7yZc3hsDV"
   },
   "source": [
    "### Summary"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "SEV_C9YJh3j0"
   },
   "source": [
    "Here we just provide the same code combined in a single chunk so you could simply copy and paste it and see the results."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 608
    },
    "executionInfo": {
     "elapsed": 14967,
     "status": "ok",
     "timestamp": 1682611824536,
     "user": {
      "displayName": "Julia Ostanina",
      "userId": "13687663492290466770"
     },
     "user_tz": -120
    },
    "id": "CS9LQhcLgzQx",
    "outputId": "df26c4b9-ed31-4fca-ec92-51f344f0e14b"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>event_id</th>\n",
       "      <th>event_type</th>\n",
       "      <th>event_index</th>\n",
       "      <th>event</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>user_id</th>\n",
       "      <th>session_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ccef9a9f-112e-4231-a1ed-109d9ca79c4a</td>\n",
       "      <td>path_start</td>\n",
       "      <td>0</td>\n",
       "      <td>path_start</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>d491bc30-e638-452f-9d34-0644c310e860</td>\n",
       "      <td>existing_user</td>\n",
       "      <td>0</td>\n",
       "      <td>existing_user</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6037d2f2-4526-432f-9335-5b1a553dbb2e</td>\n",
       "      <td>session_start</td>\n",
       "      <td>0</td>\n",
       "      <td>session_start</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>bb1f68c8-dd15-4446-b940-f9ec9688d943</td>\n",
       "      <td>raw</td>\n",
       "      <td>0</td>\n",
       "      <td>catalog</td>\n",
       "      <td>2019-11-01 17:59:13.273932</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>e19e9d4b-029e-4e8b-b077-16b77c25578c</td>\n",
       "      <td>group_alias</td>\n",
       "      <td>1</td>\n",
       "      <td>product</td>\n",
       "      <td>2019-11-01 17:59:28.459271</td>\n",
       "      <td>219483890.0</td>\n",
       "      <td>219483890.0_1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               event_id     event_type  event_index  \\\n",
       "0  ccef9a9f-112e-4231-a1ed-109d9ca79c4a     path_start            0   \n",
       "1  d491bc30-e638-452f-9d34-0644c310e860  existing_user            0   \n",
       "2  6037d2f2-4526-432f-9335-5b1a553dbb2e  session_start            0   \n",
       "3  bb1f68c8-dd15-4446-b940-f9ec9688d943            raw            0   \n",
       "4  e19e9d4b-029e-4e8b-b077-16b77c25578c    group_alias            1   \n",
       "\n",
       "           event                  timestamp      user_id     session_id  \n",
       "0     path_start 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "1  existing_user 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "2  session_start 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "3        catalog 2019-11-01 17:59:13.273932  219483890.0  219483890.0_1  \n",
       "4        product 2019-11-01 17:59:28.459271  219483890.0  219483890.0_1  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "from retentioneering import datasets\n",
    "from retentioneering.data_processors_lib import AddStartEndEvents, AddStartEndEventsParams\n",
    "from retentioneering.data_processors_lib import GroupEvents, GroupEventsParams\n",
    "from retentioneering.data_processors_lib import LabelNewUsers, LabelNewUsersParams\n",
    "from retentioneering.data_processors_lib import FilterEvents, FilterEventsParams\n",
    "from retentioneering.data_processors_lib import LabelCroppedPaths, LabelCroppedPathsParams\n",
    "from retentioneering.data_processors_lib import SplitSessions, SplitSessionsParams\n",
    "from retentioneering.preprocessing_graph import PreprocessingGraph, EventsNode, MergeNode\n",
    "\n",
    "stream = datasets.load_simple_shop()\n",
    "\n",
    "# node1\n",
    "node1 = EventsNode(AddStartEndEvents(params=AddStartEndEventsParams()))\n",
    "\n",
    "# node2\n",
    "def group_products(df, schema):\n",
    "    return df[schema.event_name].isin(['product1', 'product2'])\n",
    "\n",
    "group_events_params={\n",
    "    \"event_name\": \"product\",\n",
    "    \"func\": group_products\n",
    "}\n",
    "node2 = EventsNode(GroupEvents(params=GroupEventsParams(**group_events_params)))\n",
    "\n",
    "# node3\n",
    "google_spreadsheet_id = '1iggpIT5CZcLILLZ94wCZPQv90tERwi1IB5Y1969C8zc'\n",
    "link = f'https://docs.google.com/spreadsheets/u/1/d/{google_spreadsheet_id}/export?format=csv&id={google_spreadsheet_id}'\n",
    "new_users = pd.read_csv(link, header=None)[0].tolist()\n",
    "node3 = EventsNode(LabelNewUsers(params=LabelNewUsersParams(new_users_list=new_users)))\n",
    "\n",
    "# node4, node5\n",
    "def get_new_users(df, schema):\n",
    "    new_users = df[df[schema.event_name] == 'new_user']\\\n",
    "        [schema.user_id]\\\n",
    "        .unique()\n",
    "    return df[schema.user_id].isin(new_users)\n",
    "\n",
    "def get_existing_users(df, schema):\n",
    "    existing_users = df[df[schema.event_name] == 'existing_user']\\\n",
    "        [schema.user_id]\\\n",
    "        .unique()\n",
    "    return df[schema.user_id].isin(existing_users)\n",
    "\n",
    "node4 = EventsNode(FilterEvents(params=FilterEventsParams(func=get_new_users)))\n",
    "node5 = EventsNode(FilterEvents(params=FilterEventsParams(func=get_existing_users)))\n",
    "\n",
    "# node6\n",
    "params = {\n",
    "    \"left_cutoff\": (1, 'h'),\n",
    "    \"right_cutoff\": (1, 'h'),\n",
    "}\n",
    "node6 = EventsNode(LabelCroppedPaths(params=LabelCroppedPathsParams(**params)))\n",
    "\n",
    "# node7, node8, node9\n",
    "def remove_truncated_paths(df, schema):\n",
    "    truncated_users = df[df[schema.event_name].isin(['cropped_left', 'cropped_right'])]\\\n",
    "        [schema.user_id]\\\n",
    "        .unique()\n",
    "    return ~df[schema.user_id].isin(truncated_users)\n",
    "\n",
    "node7 = EventsNode(FilterEvents(params=FilterEventsParams(func=remove_truncated_paths)))\n",
    "node8 = MergeNode()\n",
    "node9 = EventsNode(SplitSessions(params=SplitSessionsParams(timeout=(30, 'm'))))\n",
    "\n",
    "# linking the nodes to get the graph\n",
    "pgraph = PreprocessingGraph(stream)\n",
    "pgraph.add_node(node=node1, parents=[pgraph.root])\n",
    "pgraph.add_node(node=node2, parents=[node1])\n",
    "pgraph.add_node(node=node3, parents=[node2])\n",
    "pgraph.add_node(node=node4, parents=[node3])\n",
    "pgraph.add_node(node=node5, parents=[node3])\n",
    "pgraph.add_node(node=node6, parents=[node5])\n",
    "pgraph.add_node(node=node7, parents=[node6])\n",
    "pgraph.add_node(node=node8, parents=[node4, node7])\n",
    "pgraph.add_node(node=node9, parents=[node8])\n",
    "\n",
    "# getting the calculation results\n",
    "processed_stream = pgraph.combine(node=node9)\n",
    "processed_stream.to_dataframe().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Saving preprocessing config"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div id=\"08060a81-5dd0-4515-b63e-da723cb0fbb5\">\n",
       "</div>\n",
       "<script>\n",
       "  // We render our widgets inside of iframes (to isolate javascript).\n",
       "  // The @jupyterlab/services library we use reads the basic URL parameters\n",
       "  // for the Jupyter Kernel Gateway and ws connections) from the DOM.\n",
       "  // These parameters are not present in the nested iframe.\n",
       "  // This function copies this configuration to the DOM of the current\n",
       "  // iframe so that PageConfig (https://github.com/jupyterlab/jupyterlab/blob/master/packages/coreutils/src/pageconfig.ts#L36) can retrieve them\n",
       "  function proxyNotebookEnv({ win, doc }) {\n",
       "    const topWindow = window.top\n",
       "\n",
       "    // For classic notebook\n",
       "    try {\n",
       "      const topBody = topWindow.document.body\n",
       "\n",
       "      for (const [name, val] of Object.entries(topBody.dataset)) {\n",
       "        doc.body.dataset[name] = val\n",
       "      }\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "\n",
       "    // Ror Jupyter lab\n",
       "    try {\n",
       "      if (doc.getElementById('jupyter-config-data')) {\n",
       "        return\n",
       "      }\n",
       "      const el = topWindow.document.getElementById('jupyter-config-data')\n",
       "\n",
       "      if (!el) {\n",
       "        return\n",
       "      }\n",
       "\n",
       "      const configData = el.textContent\n",
       "      const id = el.getAttribute('id')\n",
       "      const type = el.getAttribute('type')\n",
       "\n",
       "      const config = doc.createElement('script')\n",
       "      if (id) {\n",
       "        config.setAttribute('id', id)\n",
       "      }\n",
       "      if (type) {\n",
       "        config.setAttribute('type', type)\n",
       "      }\n",
       "      config.textContent = configData\n",
       "      doc.body.appendChild(config)\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function createDoctype({ doc }) {\n",
       "    const newDoctype = doc.implementation.createDocumentType('html', '', '')\n",
       "\n",
       "    if (!doc.doctype) {\n",
       "      doc.insertBefore(newDoctype, doc.childNodes[0])\n",
       "    }\n",
       "  }\n",
       "</script>\n",
       "<script>\n",
       "  (function () {\n",
       "    const width = Number(\"960\") // 960\n",
       "    const height = Number(\"600\") // 900\n",
       "\n",
       "    const iframe = document.createElement(\"iframe\")\n",
       "    iframe.src = \"about:blank\"\n",
       "    iframe.width = width\n",
       "    iframe.height = height\n",
       "\n",
       "    const renderBlock = document.getElementById(\"08060a81-5dd0-4515-b63e-da723cb0fbb5\")\n",
       "\n",
       "    const init = () => {\n",
       "      iframe.contentWindow.__SERVER_ID__ = \"c2fc3d78-ab20-42b3-9f75-f0144f8e8524\"\n",
       "      iframe.contentWindow.__ENV__ = \"classic\"\n",
       "      iframe.contentWindow.__WIDTH__ = width\n",
       "      iframe.contentWindow.__HEIGHT__ = height\n",
       "\n",
       "      \n",
       "      iframe.contentWindow.__KERNEL_ID__ = \"12d03262-e638-4c59-b238-023944106232\"\n",
       "      \n",
       "      \n",
       "      iframe.contentWindow.__TRACKING_HARDWARE_ID__ = \"fdaa9a9e-9fe1-4593-b94c-0099fabe092e\"\n",
       "      \n",
       "\n",
       "      const fDocument = iframe.contentDocument\n",
       "      const fWindow = iframe.contentWindow\n",
       "\n",
       "      createDoctype({ doc: fDocument })\n",
       "      proxyNotebookEnv({ win: fWindow, doc: fDocument })\n",
       "\n",
       "      const container = fDocument.createElement(\"div\")\n",
       "      container.id = \"root\"\n",
       "\n",
       "      const script = fDocument.createElement(\"script\")\n",
       "      script.src = \"https://static.server.retentioneering.com/package/@rete/preprocessing-graph/version/1/dist/preprocessing-graph.umd.js?block=08060a81-5dd0-4515-b63e-da723cb0fbb5\"\n",
       "      script.type = \"text/javascript\"\n",
       "\n",
       "      const link = fDocument.createElement(\"link\")\n",
       "      link.rel = \"stylesheet\"\n",
       "      link.href = \"https://static.server.retentioneering.com/package/@rete/preprocessing-graph/version/1/dist/style.css?block=08060a81-5dd0-4515-b63e-da723cb0fbb5\"\n",
       "\n",
       "      const font1 = fDocument.createElement(\"link\")\n",
       "      font1.rel = \"stylesheet\"\n",
       "      font1.href = \"https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap\"\n",
       "\n",
       "      const font2 = fDocument.createElement(\"link\")\n",
       "      font2.rel = \"stylesheet\"\n",
       "      font2.href = \"https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@300;400&display=swap\"\n",
       "\n",
       "      fDocument.body.appendChild(container)\n",
       "      fDocument.body.appendChild(script)\n",
       "      fDocument.body.appendChild(link)\n",
       "      fDocument.body.appendChild(font1)\n",
       "      fDocument.body.appendChild(font2)\n",
       "    }\n",
       "\n",
       "    iframe.onload = () => {\n",
       "      init()\n",
       "    }\n",
       "\n",
       "    renderBlock.appendChild(iframe)\n",
       "  })()\n",
       "</script>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# save preprocessing config to file\n",
    "pgraph.export_to_file('/path/to/pgraph_config.json')\n",
    "\n",
    "# load data and create new PreprocessingGraph instance\n",
    "new_stream = datasets.load_simple_shop()\n",
    "new_pgraph = new_stream.preprocessing_graph()\n",
    "\n",
    "# restore the preserved preprocessing configuration\n",
    "new_pgraph.import_from_file('/path/to/pgraph_config.json')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "hzekk6SBorGQ"
   },
   "source": [
    "Method chaining preprocessing graph\n",
    "-----------------------------------"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 942
    },
    "executionInfo": {
     "elapsed": 5,
     "status": "ok",
     "timestamp": 1682611824536,
     "user": {
      "displayName": "Julia Ostanina",
      "userId": "13687663492290466770"
     },
     "user_tz": -120
    },
    "id": "3229EogKow_k",
    "outputId": "77d5bce6-6a9d-42e2-ff8c-f937709c2fdc"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<iframe id=\"el9NUNOP\" src=\"about:blank\" width=\"960\" height=\"600\"\n",
       "  onload=\"window.reteLoadedIframes = window.reteLoadedIframes || []; window.reteLoadedIframes.push('el9NUNOP')\">\n",
       "</iframe>\n",
       "<script>\n",
       "  // We render our widgets inside of iframes (to isolate javascript).\n",
       "  // The @jupyterlab/services library we use reads the basic URL parameters\n",
       "  // for the Jupyter Kernel Gateway and ws connections) from the DOM.\n",
       "  // These parameters are not present in the nested iframe.\n",
       "  // This function copies this configuration to the DOM of the current\n",
       "  // iframe so that PageConfig (https://github.com/jupyterlab/jupyterlab/blob/master/packages/coreutils/src/pageconfig.ts#L36) can retrieve them\n",
       "  function proxyNotebookEnv({ win, doc }) {\n",
       "    const topWindow = window.top\n",
       "\n",
       "    // For classic notebook\n",
       "    try {\n",
       "      const topBody = topWindow.document.body\n",
       "\n",
       "      for (const [name, val] of Object.entries(topBody.dataset)) {\n",
       "        doc.body.dataset[name] = val\n",
       "      }\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "\n",
       "    // Ror Jupyter lab\n",
       "    try {\n",
       "      if (doc.getElementById('jupyter-config-data')) {\n",
       "        return\n",
       "      }\n",
       "      const el = topWindow.document.getElementById('jupyter-config-data')\n",
       "\n",
       "      if (!el) {\n",
       "        return\n",
       "      }\n",
       "\n",
       "      const configData = el.textContent\n",
       "      const id = el.getAttribute('id')\n",
       "      const type = el.getAttribute('type')\n",
       "\n",
       "      const config = doc.createElement('script')\n",
       "      if (id) {\n",
       "        config.setAttribute('id', id)\n",
       "      }\n",
       "      if (type) {\n",
       "        config.setAttribute('type', type)\n",
       "      }\n",
       "      config.textContent = configData\n",
       "      doc.body.appendChild(config)\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function createDoctype({ doc }) {\n",
       "    const newDoctype = doc.implementation.createDocumentType('html', '', '')\n",
       "\n",
       "    if (!doc.doctype) {\n",
       "      doc.insertBefore(newDoctype, doc.childNodes[0])\n",
       "    }\n",
       "  }\n",
       "</script><script>\n",
       "  (function () {\n",
       "    console.info('Initialize graph IFRAME')\n",
       "\n",
       "    const iframe = document.getElementById('el9NUNOP')\n",
       "    const iframeLoaded = window.reteLoadedIframes && window.reteLoadedIframes.includes('el9NUNOP')\n",
       "\n",
       "    const init = () => {\n",
       "      console.info('Graph IFRAME loaded')\n",
       "\n",
       "      const iframeDocument = document.getElementById('el9NUNOP').contentDocument\n",
       "      const iframeWindow = document.getElementById('el9NUNOP').contentDocument\n",
       "\n",
       "      iframeDocument.body.innerHTML = '<div id=\"root\"></div>'\n",
       "\n",
       "      createDoctype({ doc: iframeDocument })\n",
       "      proxyNotebookEnv({ win: iframeWindow, doc: iframeDocument })\n",
       "\n",
       "      const graphScript = iframeDocument.createElement('script')\n",
       "\n",
       "      graphScript.src = `https://static.server.retentioneering.com/package/@rete/transition-graph/version/1/dist/transition-graph.umd.js?id=elS1FI6D`\n",
       "\n",
       "      graphScript.addEventListener('load', () => {\n",
       "        console.info('JavaScript library loaded')\n",
       "\n",
       "        const initGraph = iframeDocument.createElement('script')\n",
       "\n",
       "        initGraph.innerHTML = `\n",
       "    initialize({\n",
       "    serverId: '65ca18e5-3487-4e22-9cf3-4e7bbeeea24e',\n",
       "    env: 'classic',\n",
       "    kernelId: \"31facf3e-938d-4dc7-89f4-54fb5692cd63\",\n",
       "    selectedNormalizationTypeId: 'node',\n",
       "    configNodes: [{\"index\": 0, \"name\": \"main\", \"degree\": {\"event_id\": {\"degree\": 15.64417, \"source\": 5635}, \"user_id\": {\"degree\": 23.81446, \"source\": 2385}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 1, \"name\": \"product2\", \"degree\": {\"event_id\": {\"degree\": 8.48822, \"source\": 2172}, \"user_id\": {\"degree\": 15.88037, \"source\": 1430}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 2, \"name\": \"delivery_pickup\", \"degree\": {\"event_id\": {\"degree\": 5.0456, \"source\": 506}, \"user_id\": {\"degree\": 7.89643, \"source\": 469}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 3, \"name\": \"payment_choice\", \"degree\": {\"event_id\": {\"degree\": 6.28751, \"source\": 1107}, \"user_id\": {\"degree\": 11.95901, \"source\": 958}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 4, \"name\": \"product1\", \"degree\": {\"event_id\": {\"degree\": 7.1306, \"source\": 1515}, \"user_id\": {\"degree\": 13.32152, \"source\": 1122}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 5, \"name\": \"delivery_choice\", \"degree\": {\"event_id\": {\"degree\": 7.48395, \"source\": 1686}, \"user_id\": {\"degree\": 15.26558, \"source\": 1356}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 6, \"name\": \"catalog\", \"degree\": {\"event_id\": {\"degree\": 34.0, \"source\": 14518}, \"user_id\": {\"degree\": 34.0, \"source\": 3611}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 7, \"name\": \"cart\", \"degree\": {\"event_id\": {\"degree\": 9.87271, \"source\": 2842}, \"user_id\": {\"degree\": 19.98449, \"source\": 1924}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 8, \"name\": \"payment_done\", \"degree\": {\"event_id\": {\"degree\": 5.45888, \"source\": 706}, \"user_id\": {\"degree\": 9.42509, \"source\": 653}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 9, \"name\": \"payment_cash\", \"degree\": {\"event_id\": {\"degree\": 4.40708, \"source\": 197}, \"user_id\": {\"degree\": 5.57851, \"source\": 190}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 10, \"name\": \"payment_card\", \"degree\": {\"event_id\": {\"degree\": 5.16752, \"source\": 565}, \"user_id\": {\"degree\": 8.32844, \"source\": 521}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 11, \"name\": \"delivery_courier\", \"degree\": {\"event_id\": {\"degree\": 5.72338, \"source\": 834}, \"user_id\": {\"degree\": 10.21435, \"source\": 748}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}],\n",
       "    configLinks: [{\"sourceIndex\": 7, \"targetIndex\": 7, \"weights\": {\"event_id\": {\"weight_norm\": 0.0004, \"weight\": 0.0004}, \"user_id\": {\"weight_norm\": 0.00059, \"weight\": 0.00059}}, \"type\": \"suit\"}, {\"sourceIndex\": 7, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.22923, \"weight\": 0.22923}, \"user_id\": {\"weight_norm\": 0.28385, \"weight\": 0.28385}}, \"type\": \"suit\"}, {\"sourceIndex\": 7, \"targetIndex\": 5, \"weights\": {\"event_id\": {\"weight_norm\": 0.67684, \"weight\": 0.67684}, \"user_id\": {\"weight_norm\": 0.80523, \"weight\": 0.80523}}, \"type\": \"suit\"}, {\"sourceIndex\": 7, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.09354, \"weight\": 0.09354}, \"user_id\": {\"weight_norm\": 0.12114, \"weight\": 0.12114}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 7, \"weights\": {\"event_id\": {\"weight_norm\": 0.13354, \"weight\": 0.13354}, \"user_id\": {\"weight_norm\": 0.41846, \"weight\": 0.41846}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.37951, \"weight\": 0.37951}, \"user_id\": {\"weight_norm\": 0.63338, \"weight\": 0.63338}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.19886, \"weight\": 0.19886}, \"user_id\": {\"weight_norm\": 0.46776, \"weight\": 0.46776}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 4, \"weights\": {\"event_id\": {\"weight_norm\": 0.11838, \"weight\": 0.11838}, \"user_id\": {\"weight_norm\": 0.35461, \"weight\": 0.35461}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 1, \"weights\": {\"event_id\": {\"weight_norm\": 0.16971, \"weight\": 0.16971}, \"user_id\": {\"weight_norm\": 0.45196, \"weight\": 0.45196}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.11202, \"weight\": 0.11202}, \"user_id\": {\"weight_norm\": 0.13501, \"weight\": 0.13501}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 11, \"weights\": {\"event_id\": {\"weight_norm\": 0.52486, \"weight\": 0.52486}, \"user_id\": {\"weight_norm\": 0.58713, \"weight\": 0.58713}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 2, \"weights\": {\"event_id\": {\"weight_norm\": 0.31844, \"weight\": 0.31844}, \"user_id\": {\"weight_norm\": 0.36813, \"weight\": 0.36813}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.04468, \"weight\": 0.04468}, \"user_id\": {\"weight_norm\": 0.05338, \"weight\": 0.05338}}, \"type\": \"suit\"}, {\"sourceIndex\": 11, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.04326, \"weight\": 0.04326}, \"user_id\": {\"weight_norm\": 0.04809, \"weight\": 0.04809}}, \"type\": \"suit\"}, {\"sourceIndex\": 11, \"targetIndex\": 3, \"weights\": {\"event_id\": {\"weight_norm\": 0.95674, \"weight\": 0.95674}, \"user_id\": {\"weight_norm\": 0.96605, \"weight\": 0.96605}}, \"type\": \"suit\"}, {\"sourceIndex\": 2, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.13625, \"weight\": 0.13625}, \"user_id\": {\"weight_norm\": 0.1455, \"weight\": 0.1455}}, \"type\": \"suit\"}, {\"sourceIndex\": 2, \"targetIndex\": 3, \"weights\": {\"event_id\": {\"weight_norm\": 0.86375, \"weight\": 0.86375}, \"user_id\": {\"weight_norm\": 0.87831, \"weight\": 0.87831}}, \"type\": \"suit\"}, {\"sourceIndex\": 0, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.79593, \"weight\": 0.79593}, \"user_id\": {\"weight_norm\": 0.94601, \"weight\": 0.94601}}, \"type\": \"suit\"}, {\"sourceIndex\": 0, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.20407, \"weight\": 0.20407}, \"user_id\": {\"weight_norm\": 0.2831, \"weight\": 0.2831}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.03795, \"weight\": 0.03795}, \"user_id\": {\"weight_norm\": 0.04098, \"weight\": 0.04098}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 8, \"weights\": {\"event_id\": {\"weight_norm\": 0.96205, \"weight\": 0.96205}, \"user_id\": {\"weight_norm\": 0.97336, \"weight\": 0.97336}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.31126, \"weight\": 0.31126}, \"user_id\": {\"weight_norm\": 0.3125, \"weight\": 0.3125}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 8, \"weights\": {\"event_id\": {\"weight_norm\": 0.68874, \"weight\": 0.68874}, \"user_id\": {\"weight_norm\": 0.70833, \"weight\": 0.70833}}, \"type\": \"suit\"}, {\"sourceIndex\": 3, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.11254, \"weight\": 0.11254}, \"user_id\": {\"weight_norm\": 0.12343, \"weight\": 0.12343}}, \"type\": \"suit\"}, {\"sourceIndex\": 3, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.04146, \"weight\": 0.04146}, \"user_id\": {\"weight_norm\": 0.04686, \"weight\": 0.04686}}, \"type\": \"suit\"}, {\"sourceIndex\": 3, \"targetIndex\": 10, \"weights\": {\"event_id\": {\"weight_norm\": 0.55775, \"weight\": 0.55775}, \"user_id\": {\"weight_norm\": 0.59543, \"weight\": 0.59543}}, \"type\": \"suit\"}, {\"sourceIndex\": 3, \"targetIndex\": 9, \"weights\": {\"event_id\": {\"weight_norm\": 0.19447, \"weight\": 0.19447}, \"user_id\": {\"weight_norm\": 0.21714, \"weight\": 0.21714}}, \"type\": \"suit\"}, {\"sourceIndex\": 3, \"targetIndex\": 8, \"weights\": {\"event_id\": {\"weight_norm\": 0.09378, \"weight\": 0.09378}, \"user_id\": {\"weight_norm\": 0.10743, \"weight\": 0.10743}}, \"type\": \"suit\"}, {\"sourceIndex\": 8, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"user_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}}, \"type\": \"suit\"}, {\"sourceIndex\": 4, \"targetIndex\": 7, \"weights\": {\"event_id\": {\"weight_norm\": 0.35171, \"weight\": 0.35171}, \"user_id\": {\"weight_norm\": 0.4336, \"weight\": 0.4336}}, \"type\": \"suit\"}, {\"sourceIndex\": 4, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.55887, \"weight\": 0.55887}, \"user_id\": {\"weight_norm\": 0.62374, \"weight\": 0.62374}}, \"type\": \"suit\"}, {\"sourceIndex\": 4, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.08942, \"weight\": 0.08942}, \"user_id\": {\"weight_norm\": 0.11469, \"weight\": 0.11469}}, \"type\": \"suit\"}, {\"sourceIndex\": 1, \"targetIndex\": 7, \"weights\": {\"event_id\": {\"weight_norm\": 0.32211, \"weight\": 0.32211}, \"user_id\": {\"weight_norm\": 0.43304, \"weight\": 0.43304}}, \"type\": \"suit\"}, {\"sourceIndex\": 1, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.63348, \"weight\": 0.63348}, \"user_id\": {\"weight_norm\": 0.69494, \"weight\": 0.69494}}, \"type\": \"suit\"}, {\"sourceIndex\": 1, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.04441, \"weight\": 0.04441}, \"user_id\": {\"weight_norm\": 0.06548, \"weight\": 0.06548}}, \"type\": \"suit\"}],\n",
       "    nodesColsNames: ['event_id', 'event_id', 'user_id'],\n",
       "    linksWeightsNames: ['event_id', 'event_id', 'user_id'],\n",
       "    nodesThreshold: {\"user_id\": 0.0, \"event_id\": 0.0},\n",
       "    linksThreshold: {\"user_id\": 0.0, \"event_id\": 0.0},\n",
       "    shownNodesCol: 'event_id',\n",
       "    shownLinksWeight: 'event_id',\n",
       "    selectedNodesColForThresholds: 'event_id',\n",
       "    selectedLinksWeightForThresholds: 'event_id',\n",
       "    showWeights: true,\n",
       "    showPercents: false,\n",
       "    showNodesNames: true,\n",
       "    showAllEdgesForTargets: true,\n",
       "    showNodesWithoutLinks: false,\n",
       "    showEdgesInfoOnHover: true,\n",
       "    useLayoutDump: Boolean(0),\n",
       "    weightTemplate: undefined,\n",
       "    trackingHWID: 'fdaa9a9e-9fe1-4593-b94c-0099fabe092e'\n",
       "})\n",
       "`\n",
       "        iframeDocument.body.appendChild(initGraph)\n",
       "      })\n",
       "\n",
       "      iframeDocument.head.appendChild(graphScript)\n",
       "      iframeDocument.body.dataset.templateId = 'el9NUNOP_template'\n",
       "\n",
       "      console.info('Graph IFRAME initialized')\n",
       "    }\n",
       "\n",
       "    console.log(`Graph IFRAME loaded: ` + iframeLoaded)\n",
       "\n",
       "    if (iframeLoaded) {\n",
       "      init()\n",
       "      return\n",
       "    }\n",
       "\n",
       "    iframe.onload = () => {\n",
       "      init()\n",
       "      window.reteLoadedIframes = window.reteLoadedIframes || []\n",
       "      window.reteLoadedIframes.push('el9NUNOP')\n",
       "    }\n",
       "  })()\n",
       "</script>\n",
       "\n",
       "<template id=\"el9NUNOP_template\">\n",
       "  <!DOCTYPE html>\n",
       "<html lang=\"en\">\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\"/>\n",
       "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>\n",
       "    <meta name=\"theme-color\" content=\"#000000\"/>\n",
       "    <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\"/>\n",
       "    <link crossorigin rel=\"preconnect\" href=\"https://fonts.gstatic.com\"/>\n",
       "    <link\n",
       "            crossorigin\n",
       "            href=\"https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap\"\n",
       "            rel=\"stylesheet\"\n",
       "    />\n",
       "    <title>Retentioneering Transition Graph Application</title>\n",
       "</head>\n",
       "\n",
       "<body>\n",
       "<noscript>You need to enable JavaScript to run this app.</noscript>\n",
       "<iframe id=\"elA6Y5KL\" src=\"about:blank\" width=\"960\" height=\"600\"\n",
       "  onload=\"window.reteLoadedIframes = window.reteLoadedIframes || []; window.reteLoadedIframes.push('elA6Y5KL')\">\n",
       "</iframe>\n",
       "<script>\n",
       "  // We render our widgets inside of iframes (to isolate javascript).\n",
       "  // The @jupyterlab/services library we use reads the basic URL parameters\n",
       "  // for the Jupyter Kernel Gateway and ws connections) from the DOM.\n",
       "  // These parameters are not present in the nested iframe.\n",
       "  // This function copies this configuration to the DOM of the current\n",
       "  // iframe so that PageConfig (https://github.com/jupyterlab/jupyterlab/blob/master/packages/coreutils/src/pageconfig.ts#L36) can retrieve them\n",
       "  function proxyNotebookEnv({ win, doc }) {\n",
       "    const topWindow = window.top\n",
       "\n",
       "    // For classic notebook\n",
       "    try {\n",
       "      const topBody = topWindow.document.body\n",
       "\n",
       "      for (const [name, val] of Object.entries(topBody.dataset)) {\n",
       "        doc.body.dataset[name] = val\n",
       "      }\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "\n",
       "    // Ror Jupyter lab\n",
       "    try {\n",
       "      if (doc.getElementById('jupyter-config-data')) {\n",
       "        return\n",
       "      }\n",
       "      const el = topWindow.document.getElementById('jupyter-config-data')\n",
       "\n",
       "      if (!el) {\n",
       "        return\n",
       "      }\n",
       "\n",
       "      const configData = el.textContent\n",
       "      const id = el.getAttribute('id')\n",
       "      const type = el.getAttribute('type')\n",
       "\n",
       "      const config = doc.createElement('script')\n",
       "      if (id) {\n",
       "        config.setAttribute('id', id)\n",
       "      }\n",
       "      if (type) {\n",
       "        config.setAttribute('type', type)\n",
       "      }\n",
       "      config.textContent = configData\n",
       "      doc.body.appendChild(config)\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function createDoctype({ doc }) {\n",
       "    const newDoctype = doc.implementation.createDocumentType('html', '', '')\n",
       "\n",
       "    if (!doc.doctype) {\n",
       "      doc.insertBefore(newDoctype, doc.childNodes[0])\n",
       "    }\n",
       "  }\n",
       "</script><script>\n",
       "  (function () {\n",
       "    console.info('Initialize graph IFRAME')\n",
       "\n",
       "    const iframe = document.getElementById('elA6Y5KL')\n",
       "    const iframeLoaded = window.reteLoadedIframes && window.reteLoadedIframes.includes('elA6Y5KL')\n",
       "\n",
       "    const init = () => {\n",
       "      console.info('Graph IFRAME loaded')\n",
       "\n",
       "      const iframeDocument = document.getElementById('elA6Y5KL').contentDocument\n",
       "      const iframeWindow = document.getElementById('elA6Y5KL').contentDocument\n",
       "\n",
       "      iframeDocument.body.innerHTML = '<div id=\"root\"></div>'\n",
       "\n",
       "      createDoctype({ doc: iframeDocument })\n",
       "      proxyNotebookEnv({ win: iframeWindow, doc: iframeDocument })\n",
       "\n",
       "      const graphScript = iframeDocument.createElement('script')\n",
       "\n",
       "      graphScript.src = `https://static.server.retentioneering.com/package/@rete/transition-graph/version/1/dist/transition-graph.umd.js?id=elS1FI6D`\n",
       "\n",
       "      graphScript.addEventListener('load', () => {\n",
       "        console.info('JavaScript library loaded')\n",
       "\n",
       "        const initGraph = iframeDocument.createElement('script')\n",
       "\n",
       "        initGraph.innerHTML = `\n",
       "    initialize({\n",
       "    serverId: '65ca18e5-3487-4e22-9cf3-4e7bbeeea24e',\n",
       "    env: 'classic',\n",
       "    kernelId: \"31facf3e-938d-4dc7-89f4-54fb5692cd63\",\n",
       "    selectedNormalizationTypeId: 'node',\n",
       "    configNodes: <%= nodes %>,\n",
       "    configLinks: <%= links %>,\n",
       "    nodesColsNames: ['event_id', 'event_id', 'user_id'],\n",
       "    linksWeightsNames: ['event_id', 'event_id', 'user_id'],\n",
       "    nodesThreshold: <%= nodes_threshold %>,\n",
       "    linksThreshold: <%= links_threshold %>,\n",
       "    shownNodesCol: '<%= shown_nodes_col %>',\n",
       "    shownLinksWeight: '<%= shown_links_weight %>',\n",
       "    selectedNodesColForThresholds: '<%= selected_nodes_col_for_thresholds %>',\n",
       "    selectedLinksWeightForThresholds: '<%= selected_links_weight_for_thresholds %>',\n",
       "    showWeights: <%= show_weights %>,\n",
       "    showPercents: <%= show_percents %>,\n",
       "    showNodesNames: <%= show_nodes_names %>,\n",
       "    showAllEdgesForTargets: <%= show_all_edges_for_targets %>,\n",
       "    showNodesWithoutLinks: <%= show_nodes_without_links %>,\n",
       "    showEdgesInfoOnHover: <%= show_edges_info_on_hover %>,\n",
       "    useLayoutDump: Boolean(1),\n",
       "    weightTemplate: undefined,\n",
       "    trackingHWID: 'fdaa9a9e-9fe1-4593-b94c-0099fabe092e'\n",
       "})\n",
       "`\n",
       "        iframeDocument.body.appendChild(initGraph)\n",
       "      })\n",
       "\n",
       "      iframeDocument.head.appendChild(graphScript)\n",
       "      iframeDocument.body.dataset.templateId = 'elA6Y5KL_template'\n",
       "\n",
       "      console.info('Graph IFRAME initialized')\n",
       "    }\n",
       "\n",
       "    console.log(`Graph IFRAME loaded: ` + iframeLoaded)\n",
       "\n",
       "    if (iframeLoaded) {\n",
       "      init()\n",
       "      return\n",
       "    }\n",
       "\n",
       "    iframe.onload = () => {\n",
       "      init()\n",
       "      window.reteLoadedIframes = window.reteLoadedIframes || []\n",
       "      window.reteLoadedIframes.push('elA6Y5KL')\n",
       "    }\n",
       "  })()\n",
       "</script>\n",
       "\n",
       "<template id=\"elA6Y5KL_template\">\n",
       "  \n",
       "</template>\n",
       "</body>\n",
       "</html>\n",
       "</template>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<retentioneering.tooling.transition_graph.transition_graph.TransitionGraph at 0x17e69eb20>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream.transition_graph(edges_norm_type='node')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "executionInfo": {
     "elapsed": 5052,
     "status": "ok",
     "timestamp": 1682612027013,
     "user": {
      "displayName": "Julia Ostanina",
      "userId": "13687663492290466770"
     },
     "user_tz": -120
    },
    "id": "AWB57NQdsBLB",
    "outputId": "93350811-f505-4ee4-f00e-97d16080b3cc"
   },
   "outputs": [],
   "source": [
    "def group_browsing(df, schema):\n",
    "    return df[schema.event_name].isin(['catalog', 'main'])\n",
    "\n",
    "def group_products(df, schema):\n",
    "    return df[schema.event_name].isin(['product1', 'product2'])\n",
    "\n",
    "def group_delivery(df, schema):\n",
    "    return df[schema.event_name].isin(['delivery_choice', 'delivery_courier', 'delivery_pickup'])\n",
    "\n",
    "def group_payment(df, schema):\n",
    "    return df[schema.event_name].isin(['payment_choice', 'payment_done', 'payment_card', 'payment_cash'])\n",
    "\n",
    "stream_7_nodes = stream\\\n",
    "    .drop_paths(min_steps=6)\\\n",
    "    .add_start_end_events()\\\n",
    "    .split_sessions(timeout=(30, 'm'))\\\n",
    "    .group_events(event_name='browsing', func=group_browsing)\\\n",
    "    .group_events(event_name='delivery', func=group_delivery)\\\n",
    "    .group_events(event_name='payment', func=group_payment)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 997
    },
    "executionInfo": {
     "elapsed": 3319,
     "status": "ok",
     "timestamp": 1682612030331,
     "user": {
      "displayName": "Julia Ostanina",
      "userId": "13687663492290466770"
     },
     "user_tz": -120
    },
    "id": "Ppv7B5PGo-pD",
    "outputId": "d197fb0c-403f-4e89-d4ca-5e0fa1d175e7"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<iframe id=\"elDHZ263\" src=\"about:blank\" width=\"960\" height=\"600\"\n",
       "  onload=\"window.reteLoadedIframes = window.reteLoadedIframes || []; window.reteLoadedIframes.push('elDHZ263')\">\n",
       "</iframe>\n",
       "<script>\n",
       "  // We render our widgets inside of iframes (to isolate javascript).\n",
       "  // The @jupyterlab/services library we use reads the basic URL parameters\n",
       "  // for the Jupyter Kernel Gateway and ws connections) from the DOM.\n",
       "  // These parameters are not present in the nested iframe.\n",
       "  // This function copies this configuration to the DOM of the current\n",
       "  // iframe so that PageConfig (https://github.com/jupyterlab/jupyterlab/blob/master/packages/coreutils/src/pageconfig.ts#L36) can retrieve them\n",
       "  function proxyNotebookEnv({ win, doc }) {\n",
       "    const topWindow = window.top\n",
       "\n",
       "    // For classic notebook\n",
       "    try {\n",
       "      const topBody = topWindow.document.body\n",
       "\n",
       "      for (const [name, val] of Object.entries(topBody.dataset)) {\n",
       "        doc.body.dataset[name] = val\n",
       "      }\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "\n",
       "    // Ror Jupyter lab\n",
       "    try {\n",
       "      if (doc.getElementById('jupyter-config-data')) {\n",
       "        return\n",
       "      }\n",
       "      const el = topWindow.document.getElementById('jupyter-config-data')\n",
       "\n",
       "      if (!el) {\n",
       "        return\n",
       "      }\n",
       "\n",
       "      const configData = el.textContent\n",
       "      const id = el.getAttribute('id')\n",
       "      const type = el.getAttribute('type')\n",
       "\n",
       "      const config = doc.createElement('script')\n",
       "      if (id) {\n",
       "        config.setAttribute('id', id)\n",
       "      }\n",
       "      if (type) {\n",
       "        config.setAttribute('type', type)\n",
       "      }\n",
       "      config.textContent = configData\n",
       "      doc.body.appendChild(config)\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function createDoctype({ doc }) {\n",
       "    const newDoctype = doc.implementation.createDocumentType('html', '', '')\n",
       "\n",
       "    if (!doc.doctype) {\n",
       "      doc.insertBefore(newDoctype, doc.childNodes[0])\n",
       "    }\n",
       "  }\n",
       "</script><script>\n",
       "  (function () {\n",
       "    console.info('Initialize graph IFRAME')\n",
       "\n",
       "    const iframe = document.getElementById('elDHZ263')\n",
       "    const iframeLoaded = window.reteLoadedIframes && window.reteLoadedIframes.includes('elDHZ263')\n",
       "\n",
       "    const init = () => {\n",
       "      console.info('Graph IFRAME loaded')\n",
       "\n",
       "      const iframeDocument = document.getElementById('elDHZ263').contentDocument\n",
       "      const iframeWindow = document.getElementById('elDHZ263').contentDocument\n",
       "\n",
       "      iframeDocument.body.innerHTML = '<div id=\"root\"></div>'\n",
       "\n",
       "      createDoctype({ doc: iframeDocument })\n",
       "      proxyNotebookEnv({ win: iframeWindow, doc: iframeDocument })\n",
       "\n",
       "      const graphScript = iframeDocument.createElement('script')\n",
       "\n",
       "      graphScript.src = `https://static.server.retentioneering.com/package/@rete/transition-graph/version/1/dist/transition-graph.umd.js?id=elNLEY22`\n",
       "\n",
       "      graphScript.addEventListener('load', () => {\n",
       "        console.info('JavaScript library loaded')\n",
       "\n",
       "        const initGraph = iframeDocument.createElement('script')\n",
       "\n",
       "        initGraph.innerHTML = `\n",
       "    initialize({\n",
       "    serverId: '20765ee1-d0f8-4716-8736-583db8e12736',\n",
       "    env: 'classic',\n",
       "    kernelId: \"31facf3e-938d-4dc7-89f4-54fb5692cd63\",\n",
       "    selectedNormalizationTypeId: 'node',\n",
       "    configNodes: [{\"index\": 0, \"name\": \"session_end\", \"degree\": {\"event_id\": {\"degree\": 22.90428, \"source\": 4503}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 34.0, \"source\": 4503}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 1, \"name\": \"session_start\", \"degree\": {\"event_id\": {\"degree\": 22.90428, \"source\": 4503}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 34.0, \"source\": 4503}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 2, \"name\": \"product2\", \"degree\": {\"event_id\": {\"degree\": 11.98489, \"source\": 1902}, \"user_id\": {\"degree\": 21.18689, \"source\": 1171}, \"session_id\": {\"degree\": 13.72685, \"source\": 1460}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 3, \"name\": \"path_start\", \"degree\": {\"event_id\": {\"degree\": 12.58102, \"source\": 2044}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 17.61759, \"source\": 2044}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 4, \"name\": \"path_end\", \"degree\": {\"event_id\": {\"degree\": 12.58102, \"source\": 2044}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 17.61759, \"source\": 2044}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 5, \"name\": \"product1\", \"degree\": {\"event_id\": {\"degree\": 9.49118, \"source\": 1308}, \"user_id\": {\"degree\": 17.51761, \"source\": 921}, \"session_id\": {\"degree\": 11.32845, \"source\": 1100}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 6, \"name\": \"cart\", \"degree\": {\"event_id\": {\"degree\": 14.54156, \"source\": 2511}, \"user_id\": {\"degree\": 27.49804, \"source\": 1601}, \"session_id\": {\"degree\": 18.21053, \"source\": 2133}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 7, \"name\": \"payment\", \"degree\": {\"event_id\": {\"degree\": 8.61797, \"source\": 1100}, \"user_id\": {\"degree\": 17.95793, \"source\": 951}, \"session_id\": {\"degree\": 11.14191, \"source\": 1072}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 8, \"name\": \"delivery\", \"degree\": {\"event_id\": {\"degree\": 10.67926, \"source\": 1591}, \"user_id\": {\"degree\": 22.50783, \"source\": 1261}, \"session_id\": {\"degree\": 14.09327, \"source\": 1515}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 9, \"name\": \"browsing\", \"degree\": {\"event_id\": {\"degree\": 34.0, \"source\": 7146}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 34.0, \"source\": 4503}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}],\n",
       "    configLinks: [{\"sourceIndex\": 9, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.20795, \"weight\": 0.20795}, \"user_id\": {\"weight_norm\": 0.54159, \"weight\": 0.54159}, \"session_id\": {\"weight_norm\": 0.29936, \"weight\": 0.29936}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 5, \"weights\": {\"event_id\": {\"weight_norm\": 0.18304, \"weight\": 0.18304}, \"user_id\": {\"weight_norm\": 0.45059, \"weight\": 0.45059}, \"session_id\": {\"weight_norm\": 0.24428, \"weight\": 0.24428}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 2, \"weights\": {\"event_id\": {\"weight_norm\": 0.26616, \"weight\": 0.26616}, \"user_id\": {\"weight_norm\": 0.5729, \"weight\": 0.5729}, \"session_id\": {\"weight_norm\": 0.32423, \"weight\": 0.32423}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.34285, \"weight\": 0.34285}, \"user_id\": {\"weight_norm\": 0.6091, \"weight\": 0.6091}, \"session_id\": {\"weight_norm\": 0.54408, \"weight\": 0.54408}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 9, \"weights\": {\"event_id\": {\"weight_norm\": 0.20589, \"weight\": 0.20589}, \"user_id\": {\"weight_norm\": 0.26483, \"weight\": 0.26483}, \"session_id\": {\"weight_norm\": 0.21613, \"weight\": 0.21613}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 8, \"weights\": {\"event_id\": {\"weight_norm\": 0.63361, \"weight\": 0.63361}, \"user_id\": {\"weight_norm\": 0.78763, \"weight\": 0.78763}, \"session_id\": {\"weight_norm\": 0.71027, \"weight\": 0.71027}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.16049, \"weight\": 0.16049}, \"user_id\": {\"weight_norm\": 0.22236, \"weight\": 0.22236}, \"session_id\": {\"weight_norm\": 0.18894, \"weight\": 0.18894}}, \"type\": \"suit\"}, {\"sourceIndex\": 8, \"targetIndex\": 9, \"weights\": {\"event_id\": {\"weight_norm\": 0.10371, \"weight\": 0.10371}, \"user_id\": {\"weight_norm\": 0.12609, \"weight\": 0.12609}, \"session_id\": {\"weight_norm\": 0.10759, \"weight\": 0.10759}}, \"type\": \"suit\"}, {\"sourceIndex\": 8, \"targetIndex\": 7, \"weights\": {\"event_id\": {\"weight_norm\": 0.69139, \"weight\": 0.69139}, \"user_id\": {\"weight_norm\": 0.75416, \"weight\": 0.75416}, \"session_id\": {\"weight_norm\": 0.70759, \"weight\": 0.70759}}, \"type\": \"suit\"}, {\"sourceIndex\": 8, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.2049, \"weight\": 0.2049}, \"user_id\": {\"weight_norm\": 0.23315, \"weight\": 0.23315}, \"session_id\": {\"weight_norm\": 0.21518, \"weight\": 0.21518}}, \"type\": \"suit\"}, {\"sourceIndex\": 3, \"targetIndex\": 1, \"weights\": {\"event_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"user_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"session_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}}, \"type\": \"suit\"}, {\"sourceIndex\": 7, \"targetIndex\": 9, \"weights\": {\"event_id\": {\"weight_norm\": 0.10364, \"weight\": 0.10364}, \"user_id\": {\"weight_norm\": 0.11356, \"weight\": 0.11356}, \"session_id\": {\"weight_norm\": 0.10261, \"weight\": 0.10261}}, \"type\": \"suit\"}, {\"sourceIndex\": 7, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.89636, \"weight\": 0.89636}, \"user_id\": {\"weight_norm\": 0.92955, \"weight\": 0.92955}, \"session_id\": {\"weight_norm\": 0.91978, \"weight\": 0.91978}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 9, \"weights\": {\"event_id\": {\"weight_norm\": 0.51682, \"weight\": 0.51682}, \"user_id\": {\"weight_norm\": 0.59175, \"weight\": 0.59175}, \"session_id\": {\"weight_norm\": 0.53636, \"weight\": 0.53636}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.32951, \"weight\": 0.32951}, \"user_id\": {\"weight_norm\": 0.42345, \"weight\": 0.42345}, \"session_id\": {\"weight_norm\": 0.37636, \"weight\": 0.37636}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.15367, \"weight\": 0.15367}, \"user_id\": {\"weight_norm\": 0.20521, \"weight\": 0.20521}, \"session_id\": {\"weight_norm\": 0.18273, \"weight\": 0.18273}}, \"type\": \"suit\"}, {\"sourceIndex\": 2, \"targetIndex\": 9, \"weights\": {\"event_id\": {\"weight_norm\": 0.61567, \"weight\": 0.61567}, \"user_id\": {\"weight_norm\": 0.69086, \"weight\": 0.69086}, \"session_id\": {\"weight_norm\": 0.64247, \"weight\": 0.64247}}, \"type\": \"suit\"}, {\"sourceIndex\": 2, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.3123, \"weight\": 0.3123}, \"user_id\": {\"weight_norm\": 0.44065, \"weight\": 0.44065}, \"session_id\": {\"weight_norm\": 0.38493, \"weight\": 0.38493}}, \"type\": \"suit\"}, {\"sourceIndex\": 2, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.07203, \"weight\": 0.07203}, \"user_id\": {\"weight_norm\": 0.11358, \"weight\": 0.11358}, \"session_id\": {\"weight_norm\": 0.09384, \"weight\": 0.09384}}, \"type\": \"suit\"}, {\"sourceIndex\": 0, \"targetIndex\": 4, \"weights\": {\"event_id\": {\"weight_norm\": 0.45392, \"weight\": 0.45392}, \"user_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"session_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}}, \"type\": \"suit\"}, {\"sourceIndex\": 0, \"targetIndex\": 1, \"weights\": {\"event_id\": {\"weight_norm\": 0.54608, \"weight\": 0.54608}, \"user_id\": {\"weight_norm\": 0.54452, \"weight\": 0.54452}}, \"type\": \"suit\"}, {\"sourceIndex\": 1, \"targetIndex\": 9, \"weights\": {\"event_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"user_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"session_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}}, \"type\": \"suit\"}],\n",
       "    nodesColsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    linksWeightsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    nodesThreshold: {\"user_id\": 0.0, \"event_id\": 0.0},\n",
       "    linksThreshold: {\"user_id\": 0.0, \"event_id\": 0.0},\n",
       "    shownNodesCol: 'event_id',\n",
       "    shownLinksWeight: 'event_id',\n",
       "    selectedNodesColForThresholds: 'event_id',\n",
       "    selectedLinksWeightForThresholds: 'event_id',\n",
       "    showWeights: true,\n",
       "    showPercents: false,\n",
       "    showNodesNames: true,\n",
       "    showAllEdgesForTargets: true,\n",
       "    showNodesWithoutLinks: false,\n",
       "    showEdgesInfoOnHover: true,\n",
       "    useLayoutDump: Boolean(0),\n",
       "    weightTemplate: undefined,\n",
       "    trackingHWID: 'fdaa9a9e-9fe1-4593-b94c-0099fabe092e'\n",
       "})\n",
       "`\n",
       "        iframeDocument.body.appendChild(initGraph)\n",
       "      })\n",
       "\n",
       "      iframeDocument.head.appendChild(graphScript)\n",
       "      iframeDocument.body.dataset.templateId = 'elDHZ263_template'\n",
       "\n",
       "      console.info('Graph IFRAME initialized')\n",
       "    }\n",
       "\n",
       "    console.log(`Graph IFRAME loaded: ` + iframeLoaded)\n",
       "\n",
       "    if (iframeLoaded) {\n",
       "      init()\n",
       "      return\n",
       "    }\n",
       "\n",
       "    iframe.onload = () => {\n",
       "      init()\n",
       "      window.reteLoadedIframes = window.reteLoadedIframes || []\n",
       "      window.reteLoadedIframes.push('elDHZ263')\n",
       "    }\n",
       "  })()\n",
       "</script>\n",
       "\n",
       "<template id=\"elDHZ263_template\">\n",
       "  <!DOCTYPE html>\n",
       "<html lang=\"en\">\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\"/>\n",
       "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>\n",
       "    <meta name=\"theme-color\" content=\"#000000\"/>\n",
       "    <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\"/>\n",
       "    <link crossorigin rel=\"preconnect\" href=\"https://fonts.gstatic.com\"/>\n",
       "    <link\n",
       "            crossorigin\n",
       "            href=\"https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap\"\n",
       "            rel=\"stylesheet\"\n",
       "    />\n",
       "    <title>Retentioneering Transition Graph Application</title>\n",
       "</head>\n",
       "\n",
       "<body>\n",
       "<noscript>You need to enable JavaScript to run this app.</noscript>\n",
       "<iframe id=\"elAW01UM\" src=\"about:blank\" width=\"960\" height=\"600\"\n",
       "  onload=\"window.reteLoadedIframes = window.reteLoadedIframes || []; window.reteLoadedIframes.push('elAW01UM')\">\n",
       "</iframe>\n",
       "<script>\n",
       "  // We render our widgets inside of iframes (to isolate javascript).\n",
       "  // The @jupyterlab/services library we use reads the basic URL parameters\n",
       "  // for the Jupyter Kernel Gateway and ws connections) from the DOM.\n",
       "  // These parameters are not present in the nested iframe.\n",
       "  // This function copies this configuration to the DOM of the current\n",
       "  // iframe so that PageConfig (https://github.com/jupyterlab/jupyterlab/blob/master/packages/coreutils/src/pageconfig.ts#L36) can retrieve them\n",
       "  function proxyNotebookEnv({ win, doc }) {\n",
       "    const topWindow = window.top\n",
       "\n",
       "    // For classic notebook\n",
       "    try {\n",
       "      const topBody = topWindow.document.body\n",
       "\n",
       "      for (const [name, val] of Object.entries(topBody.dataset)) {\n",
       "        doc.body.dataset[name] = val\n",
       "      }\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "\n",
       "    // Ror Jupyter lab\n",
       "    try {\n",
       "      if (doc.getElementById('jupyter-config-data')) {\n",
       "        return\n",
       "      }\n",
       "      const el = topWindow.document.getElementById('jupyter-config-data')\n",
       "\n",
       "      if (!el) {\n",
       "        return\n",
       "      }\n",
       "\n",
       "      const configData = el.textContent\n",
       "      const id = el.getAttribute('id')\n",
       "      const type = el.getAttribute('type')\n",
       "\n",
       "      const config = doc.createElement('script')\n",
       "      if (id) {\n",
       "        config.setAttribute('id', id)\n",
       "      }\n",
       "      if (type) {\n",
       "        config.setAttribute('type', type)\n",
       "      }\n",
       "      config.textContent = configData\n",
       "      doc.body.appendChild(config)\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function createDoctype({ doc }) {\n",
       "    const newDoctype = doc.implementation.createDocumentType('html', '', '')\n",
       "\n",
       "    if (!doc.doctype) {\n",
       "      doc.insertBefore(newDoctype, doc.childNodes[0])\n",
       "    }\n",
       "  }\n",
       "</script><script>\n",
       "  (function () {\n",
       "    console.info('Initialize graph IFRAME')\n",
       "\n",
       "    const iframe = document.getElementById('elAW01UM')\n",
       "    const iframeLoaded = window.reteLoadedIframes && window.reteLoadedIframes.includes('elAW01UM')\n",
       "\n",
       "    const init = () => {\n",
       "      console.info('Graph IFRAME loaded')\n",
       "\n",
       "      const iframeDocument = document.getElementById('elAW01UM').contentDocument\n",
       "      const iframeWindow = document.getElementById('elAW01UM').contentDocument\n",
       "\n",
       "      iframeDocument.body.innerHTML = '<div id=\"root\"></div>'\n",
       "\n",
       "      createDoctype({ doc: iframeDocument })\n",
       "      proxyNotebookEnv({ win: iframeWindow, doc: iframeDocument })\n",
       "\n",
       "      const graphScript = iframeDocument.createElement('script')\n",
       "\n",
       "      graphScript.src = `https://static.server.retentioneering.com/package/@rete/transition-graph/version/1/dist/transition-graph.umd.js?id=elNLEY22`\n",
       "\n",
       "      graphScript.addEventListener('load', () => {\n",
       "        console.info('JavaScript library loaded')\n",
       "\n",
       "        const initGraph = iframeDocument.createElement('script')\n",
       "\n",
       "        initGraph.innerHTML = `\n",
       "    initialize({\n",
       "    serverId: '20765ee1-d0f8-4716-8736-583db8e12736',\n",
       "    env: 'classic',\n",
       "    kernelId: \"31facf3e-938d-4dc7-89f4-54fb5692cd63\",\n",
       "    selectedNormalizationTypeId: 'node',\n",
       "    configNodes: <%= nodes %>,\n",
       "    configLinks: <%= links %>,\n",
       "    nodesColsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    linksWeightsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    nodesThreshold: <%= nodes_threshold %>,\n",
       "    linksThreshold: <%= links_threshold %>,\n",
       "    shownNodesCol: '<%= shown_nodes_col %>',\n",
       "    shownLinksWeight: '<%= shown_links_weight %>',\n",
       "    selectedNodesColForThresholds: '<%= selected_nodes_col_for_thresholds %>',\n",
       "    selectedLinksWeightForThresholds: '<%= selected_links_weight_for_thresholds %>',\n",
       "    showWeights: <%= show_weights %>,\n",
       "    showPercents: <%= show_percents %>,\n",
       "    showNodesNames: <%= show_nodes_names %>,\n",
       "    showAllEdgesForTargets: <%= show_all_edges_for_targets %>,\n",
       "    showNodesWithoutLinks: <%= show_nodes_without_links %>,\n",
       "    showEdgesInfoOnHover: <%= show_edges_info_on_hover %>,\n",
       "    useLayoutDump: Boolean(1),\n",
       "    weightTemplate: undefined,\n",
       "    trackingHWID: 'fdaa9a9e-9fe1-4593-b94c-0099fabe092e'\n",
       "})\n",
       "`\n",
       "        iframeDocument.body.appendChild(initGraph)\n",
       "      })\n",
       "\n",
       "      iframeDocument.head.appendChild(graphScript)\n",
       "      iframeDocument.body.dataset.templateId = 'elAW01UM_template'\n",
       "\n",
       "      console.info('Graph IFRAME initialized')\n",
       "    }\n",
       "\n",
       "    console.log(`Graph IFRAME loaded: ` + iframeLoaded)\n",
       "\n",
       "    if (iframeLoaded) {\n",
       "      init()\n",
       "      return\n",
       "    }\n",
       "\n",
       "    iframe.onload = () => {\n",
       "      init()\n",
       "      window.reteLoadedIframes = window.reteLoadedIframes || []\n",
       "      window.reteLoadedIframes.push('elAW01UM')\n",
       "    }\n",
       "  })()\n",
       "</script>\n",
       "\n",
       "<template id=\"elAW01UM_template\">\n",
       "  \n",
       "</template>\n",
       "</body>\n",
       "</html>\n",
       "</template>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<retentioneering.tooling.transition_graph.transition_graph.TransitionGraph at 0x17efa0e80>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream_out = stream_7_nodes.collapse_loops()\n",
    "stream_out.transition_graph(edges_norm_type='node')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 997
    },
    "executionInfo": {
     "elapsed": 6740,
     "status": "ok",
     "timestamp": 1682612083442,
     "user": {
      "displayName": "Julia Ostanina",
      "userId": "13687663492290466770"
     },
     "user_tz": -120
    },
    "id": "K8WXtrzAsZEF",
    "outputId": "233bb24f-1706-439e-b0a2-cdebfb80328c"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<iframe id=\"elNGHFJE\" src=\"about:blank\" width=\"960\" height=\"600\"\n",
       "  onload=\"window.reteLoadedIframes = window.reteLoadedIframes || []; window.reteLoadedIframes.push('elNGHFJE')\">\n",
       "</iframe>\n",
       "<script>\n",
       "  // We render our widgets inside of iframes (to isolate javascript).\n",
       "  // The @jupyterlab/services library we use reads the basic URL parameters\n",
       "  // for the Jupyter Kernel Gateway and ws connections) from the DOM.\n",
       "  // These parameters are not present in the nested iframe.\n",
       "  // This function copies this configuration to the DOM of the current\n",
       "  // iframe so that PageConfig (https://github.com/jupyterlab/jupyterlab/blob/master/packages/coreutils/src/pageconfig.ts#L36) can retrieve them\n",
       "  function proxyNotebookEnv({ win, doc }) {\n",
       "    const topWindow = window.top\n",
       "\n",
       "    // For classic notebook\n",
       "    try {\n",
       "      const topBody = topWindow.document.body\n",
       "\n",
       "      for (const [name, val] of Object.entries(topBody.dataset)) {\n",
       "        doc.body.dataset[name] = val\n",
       "      }\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "\n",
       "    // Ror Jupyter lab\n",
       "    try {\n",
       "      if (doc.getElementById('jupyter-config-data')) {\n",
       "        return\n",
       "      }\n",
       "      const el = topWindow.document.getElementById('jupyter-config-data')\n",
       "\n",
       "      if (!el) {\n",
       "        return\n",
       "      }\n",
       "\n",
       "      const configData = el.textContent\n",
       "      const id = el.getAttribute('id')\n",
       "      const type = el.getAttribute('type')\n",
       "\n",
       "      const config = doc.createElement('script')\n",
       "      if (id) {\n",
       "        config.setAttribute('id', id)\n",
       "      }\n",
       "      if (type) {\n",
       "        config.setAttribute('type', type)\n",
       "      }\n",
       "      config.textContent = configData\n",
       "      doc.body.appendChild(config)\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function createDoctype({ doc }) {\n",
       "    const newDoctype = doc.implementation.createDocumentType('html', '', '')\n",
       "\n",
       "    if (!doc.doctype) {\n",
       "      doc.insertBefore(newDoctype, doc.childNodes[0])\n",
       "    }\n",
       "  }\n",
       "</script><script>\n",
       "  (function () {\n",
       "    console.info('Initialize graph IFRAME')\n",
       "\n",
       "    const iframe = document.getElementById('elNGHFJE')\n",
       "    const iframeLoaded = window.reteLoadedIframes && window.reteLoadedIframes.includes('elNGHFJE')\n",
       "\n",
       "    const init = () => {\n",
       "      console.info('Graph IFRAME loaded')\n",
       "\n",
       "      const iframeDocument = document.getElementById('elNGHFJE').contentDocument\n",
       "      const iframeWindow = document.getElementById('elNGHFJE').contentDocument\n",
       "\n",
       "      iframeDocument.body.innerHTML = '<div id=\"root\"></div>'\n",
       "\n",
       "      createDoctype({ doc: iframeDocument })\n",
       "      proxyNotebookEnv({ win: iframeWindow, doc: iframeDocument })\n",
       "\n",
       "      const graphScript = iframeDocument.createElement('script')\n",
       "\n",
       "      graphScript.src = `https://static.server.retentioneering.com/package/@rete/transition-graph/version/1/dist/transition-graph.umd.js?id=el0I7LXX`\n",
       "\n",
       "      graphScript.addEventListener('load', () => {\n",
       "        console.info('JavaScript library loaded')\n",
       "\n",
       "        const initGraph = iframeDocument.createElement('script')\n",
       "\n",
       "        initGraph.innerHTML = `\n",
       "    initialize({\n",
       "    serverId: 'b0b062e5-2263-40ad-aead-7a5dbd15278d',\n",
       "    env: 'classic',\n",
       "    kernelId: \"31facf3e-938d-4dc7-89f4-54fb5692cd63\",\n",
       "    selectedNormalizationTypeId: 'node',\n",
       "    configNodes: [{\"index\": 0, \"name\": \"session_end\", \"degree\": {\"event_id\": {\"degree\": 34.0, \"source\": 4503}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 34.0, \"source\": 4503}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 1, \"name\": \"session_start\", \"degree\": {\"event_id\": {\"degree\": 34.0, \"source\": 4503}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 34.0, \"source\": 4503}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 2, \"name\": \"product2\", \"degree\": {\"event_id\": {\"degree\": 16.67155, \"source\": 1902}, \"user_id\": {\"degree\": 21.18689, \"source\": 1171}, \"session_id\": {\"degree\": 13.72685, \"source\": 1460}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 3, \"name\": \"path_start\", \"degree\": {\"event_id\": {\"degree\": 17.61759, \"source\": 2044}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 17.61759, \"source\": 2044}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 4, \"name\": \"path_end\", \"degree\": {\"event_id\": {\"degree\": 17.61759, \"source\": 2044}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 17.61759, \"source\": 2044}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 5, \"name\": \"product1\", \"degree\": {\"event_id\": {\"degree\": 12.71419, \"source\": 1308}, \"user_id\": {\"degree\": 17.51761, \"source\": 921}, \"session_id\": {\"degree\": 11.32845, \"source\": 1100}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 6, \"name\": \"cart\", \"degree\": {\"event_id\": {\"degree\": 20.72219, \"source\": 2510}, \"user_id\": {\"degree\": 27.49804, \"source\": 1601}, \"session_id\": {\"degree\": 18.20386, \"source\": 2132}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 7, \"name\": \"delivery_loop\", \"degree\": {\"event_id\": {\"degree\": 12.66755, \"source\": 1301}, \"user_id\": {\"degree\": 20.15949, \"source\": 1101}, \"session_id\": {\"degree\": 12.46103, \"source\": 1270}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 8, \"name\": \"payment\", \"degree\": {\"event_id\": {\"degree\": 5.61892, \"source\": 243}, \"user_id\": {\"degree\": 7.28767, \"source\": 224}, \"session_id\": {\"degree\": 5.5523, \"source\": 233}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 9, \"name\": \"delivery\", \"degree\": {\"event_id\": {\"degree\": 5.93205, \"source\": 290}, \"user_id\": {\"degree\": 7.9775, \"source\": 271}, \"session_id\": {\"degree\": 5.87875, \"source\": 282}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 10, \"name\": \"browsing_loop\", \"degree\": {\"event_id\": {\"degree\": 32.96069, \"source\": 4347}, \"user_id\": {\"degree\": 30.94716, \"source\": 1836}, \"session_id\": {\"degree\": 26.63158, \"source\": 3397}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 11, \"name\": \"payment_loop\", \"degree\": {\"event_id\": {\"degree\": 9.70953, \"source\": 857}, \"user_id\": {\"degree\": 15.36008, \"source\": 774}, \"session_id\": {\"degree\": 9.70953, \"source\": 857}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 12, \"name\": \"cart_loop\", \"degree\": {\"event_id\": {\"degree\": 4.00666, \"source\": 1}, \"user_id\": {\"degree\": 4.01468, \"source\": 1}, \"session_id\": {\"degree\": 4.00666, \"source\": 1}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 13, \"name\": \"browsing\", \"degree\": {\"event_id\": {\"degree\": 22.64757, \"source\": 2799}, \"user_id\": {\"degree\": 24.60665, \"source\": 1404}, \"session_id\": {\"degree\": 18.58361, \"source\": 2189}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}],\n",
       "    configLinks: [{\"sourceIndex\": 13, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.18864, \"weight\": 0.18864}, \"user_id\": {\"weight_norm\": 0.33689, \"weight\": 0.33689}, \"session_id\": {\"weight_norm\": 0.22841, \"weight\": 0.22841}}, \"type\": \"suit\"}, {\"sourceIndex\": 13, \"targetIndex\": 5, \"weights\": {\"event_id\": {\"weight_norm\": 0.15791, \"weight\": 0.15791}, \"user_id\": {\"weight_norm\": 0.27493, \"weight\": 0.27493}, \"session_id\": {\"weight_norm\": 0.18365, \"weight\": 0.18365}}, \"type\": \"suit\"}, {\"sourceIndex\": 13, \"targetIndex\": 2, \"weights\": {\"event_id\": {\"weight_norm\": 0.24652, \"weight\": 0.24652}, \"user_id\": {\"weight_norm\": 0.39316, \"weight\": 0.39316}, \"session_id\": {\"weight_norm\": 0.26405, \"weight\": 0.26405}}, \"type\": \"suit\"}, {\"sourceIndex\": 13, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.40693, \"weight\": 0.40693}, \"user_id\": {\"weight_norm\": 0.48504, \"weight\": 0.48504}, \"session_id\": {\"weight_norm\": 0.52033, \"weight\": 0.52033}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.22015, \"weight\": 0.22015}, \"user_id\": {\"weight_norm\": 0.41993, \"weight\": 0.41993}, \"session_id\": {\"weight_norm\": 0.27053, \"weight\": 0.27053}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.00023, \"weight\": 0.00023}, \"user_id\": {\"weight_norm\": 0.00054, \"weight\": 0.00054}, \"session_id\": {\"weight_norm\": 0.00029, \"weight\": 0.00029}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 5, \"weights\": {\"event_id\": {\"weight_norm\": 0.19922, \"weight\": 0.19922}, \"user_id\": {\"weight_norm\": 0.37854, \"weight\": 0.37854}, \"session_id\": {\"weight_norm\": 0.23432, \"weight\": 0.23432}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 2, \"weights\": {\"event_id\": {\"weight_norm\": 0.27881, \"weight\": 0.27881}, \"user_id\": {\"weight_norm\": 0.47767, \"weight\": 0.47767}, \"session_id\": {\"weight_norm\": 0.31969, \"weight\": 0.31969}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.30159, \"weight\": 0.30159}, \"user_id\": {\"weight_norm\": 0.48693, \"weight\": 0.48693}, \"session_id\": {\"weight_norm\": 0.38593, \"weight\": 0.38593}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 13, \"weights\": {\"event_id\": {\"weight_norm\": 0.11116, \"weight\": 0.11116}, \"user_id\": {\"weight_norm\": 0.15116, \"weight\": 0.15116}, \"session_id\": {\"weight_norm\": 0.12008, \"weight\": 0.12008}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 10, \"weights\": {\"event_id\": {\"weight_norm\": 0.09482, \"weight\": 0.09482}, \"user_id\": {\"weight_norm\": 0.13991, \"weight\": 0.13991}, \"session_id\": {\"weight_norm\": 0.10788, \"weight\": 0.10788}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 9, \"weights\": {\"event_id\": {\"weight_norm\": 0.11554, \"weight\": 0.11554}, \"user_id\": {\"weight_norm\": 0.16927, \"weight\": 0.16927}, \"session_id\": {\"weight_norm\": 0.13227, \"weight\": 0.13227}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 7, \"weights\": {\"event_id\": {\"weight_norm\": 0.51793, \"weight\": 0.51793}, \"user_id\": {\"weight_norm\": 0.6877, \"weight\": 0.6877}, \"session_id\": {\"weight_norm\": 0.59522, \"weight\": 0.59522}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.16056, \"weight\": 0.16056}, \"user_id\": {\"weight_norm\": 0.22236, \"weight\": 0.22236}, \"session_id\": {\"weight_norm\": 0.18902, \"weight\": 0.18902}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 7, \"weights\": {\"event_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"user_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"session_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 13, \"weights\": {\"event_id\": {\"weight_norm\": 0.31034, \"weight\": 0.31034}, \"user_id\": {\"weight_norm\": 0.31734, \"weight\": 0.31734}, \"session_id\": {\"weight_norm\": 0.31915, \"weight\": 0.31915}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 10, \"weights\": {\"event_id\": {\"weight_norm\": 0.25862, \"weight\": 0.25862}, \"user_id\": {\"weight_norm\": 0.27675, \"weight\": 0.27675}, \"session_id\": {\"weight_norm\": 0.26596, \"weight\": 0.26596}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.43103, \"weight\": 0.43103}, \"user_id\": {\"weight_norm\": 0.44649, \"weight\": 0.44649}, \"session_id\": {\"weight_norm\": 0.44326, \"weight\": 0.44326}}, \"type\": \"suit\"}, {\"sourceIndex\": 7, \"targetIndex\": 8, \"weights\": {\"event_id\": {\"weight_norm\": 0.18678, \"weight\": 0.18678}, \"user_id\": {\"weight_norm\": 0.20345, \"weight\": 0.20345}, \"session_id\": {\"weight_norm\": 0.18346, \"weight\": 0.18346}}, \"type\": \"suit\"}, {\"sourceIndex\": 7, \"targetIndex\": 11, \"weights\": {\"event_id\": {\"weight_norm\": 0.65872, \"weight\": 0.65872}, \"user_id\": {\"weight_norm\": 0.703, \"weight\": 0.703}, \"session_id\": {\"weight_norm\": 0.6748, \"weight\": 0.6748}}, \"type\": \"suit\"}, {\"sourceIndex\": 7, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.1545, \"weight\": 0.1545}, \"user_id\": {\"weight_norm\": 0.17439, \"weight\": 0.17439}, \"session_id\": {\"weight_norm\": 0.15827, \"weight\": 0.15827}}, \"type\": \"suit\"}, {\"sourceIndex\": 3, \"targetIndex\": 1, \"weights\": {\"event_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"user_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"session_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}}, \"type\": \"suit\"}, {\"sourceIndex\": 8, \"targetIndex\": 13, \"weights\": {\"event_id\": {\"weight_norm\": 0.24691, \"weight\": 0.24691}, \"user_id\": {\"weight_norm\": 0.25893, \"weight\": 0.25893}, \"session_id\": {\"weight_norm\": 0.24893, \"weight\": 0.24893}}, \"type\": \"suit\"}, {\"sourceIndex\": 8, \"targetIndex\": 10, \"weights\": {\"event_id\": {\"weight_norm\": 0.22222, \"weight\": 0.22222}, \"user_id\": {\"weight_norm\": 0.23661, \"weight\": 0.23661}, \"session_id\": {\"weight_norm\": 0.22747, \"weight\": 0.22747}}, \"type\": \"suit\"}, {\"sourceIndex\": 8, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.53086, \"weight\": 0.53086}, \"user_id\": {\"weight_norm\": 0.57143, \"weight\": 0.57143}, \"session_id\": {\"weight_norm\": 0.55365, \"weight\": 0.55365}}, \"type\": \"suit\"}, {\"sourceIndex\": 11, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"user_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"session_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 13, \"weights\": {\"event_id\": {\"weight_norm\": 0.2867, \"weight\": 0.2867}, \"user_id\": {\"weight_norm\": 0.35505, \"weight\": 0.35505}, \"session_id\": {\"weight_norm\": 0.31818, \"weight\": 0.31818}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 10, \"weights\": {\"event_id\": {\"weight_norm\": 0.23012, \"weight\": 0.23012}, \"user_id\": {\"weight_norm\": 0.29207, \"weight\": 0.29207}, \"session_id\": {\"weight_norm\": 0.25091, \"weight\": 0.25091}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.32951, \"weight\": 0.32951}, \"user_id\": {\"weight_norm\": 0.42345, \"weight\": 0.42345}, \"session_id\": {\"weight_norm\": 0.37636, \"weight\": 0.37636}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.15367, \"weight\": 0.15367}, \"user_id\": {\"weight_norm\": 0.20521, \"weight\": 0.20521}, \"session_id\": {\"weight_norm\": 0.18273, \"weight\": 0.18273}}, \"type\": \"suit\"}, {\"sourceIndex\": 2, \"targetIndex\": 13, \"weights\": {\"event_id\": {\"weight_norm\": 0.34648, \"weight\": 0.34648}, \"user_id\": {\"weight_norm\": 0.44236, \"weight\": 0.44236}, \"session_id\": {\"weight_norm\": 0.39932, \"weight\": 0.39932}}, \"type\": \"suit\"}, {\"sourceIndex\": 2, \"targetIndex\": 10, \"weights\": {\"event_id\": {\"weight_norm\": 0.26919, \"weight\": 0.26919}, \"user_id\": {\"weight_norm\": 0.37489, \"weight\": 0.37489}, \"session_id\": {\"weight_norm\": 0.31986, \"weight\": 0.31986}}, \"type\": \"suit\"}, {\"sourceIndex\": 2, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.3123, \"weight\": 0.3123}, \"user_id\": {\"weight_norm\": 0.44065, \"weight\": 0.44065}, \"session_id\": {\"weight_norm\": 0.38493, \"weight\": 0.38493}}, \"type\": \"suit\"}, {\"sourceIndex\": 2, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.07203, \"weight\": 0.07203}, \"user_id\": {\"weight_norm\": 0.11358, \"weight\": 0.11358}, \"session_id\": {\"weight_norm\": 0.09384, \"weight\": 0.09384}}, \"type\": \"suit\"}, {\"sourceIndex\": 0, \"targetIndex\": 4, \"weights\": {\"event_id\": {\"weight_norm\": 0.45392, \"weight\": 0.45392}, \"user_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}, \"session_id\": {\"weight_norm\": 1.0, \"weight\": 1.0}}, \"type\": \"suit\"}, {\"sourceIndex\": 0, \"targetIndex\": 1, \"weights\": {\"event_id\": {\"weight_norm\": 0.54608, \"weight\": 0.54608}, \"user_id\": {\"weight_norm\": 0.54452, \"weight\": 0.54452}}, \"type\": \"suit\"}, {\"sourceIndex\": 1, \"targetIndex\": 13, \"weights\": {\"event_id\": {\"weight_norm\": 0.29669, \"weight\": 0.29669}, \"user_id\": {\"weight_norm\": 0.44863, \"weight\": 0.44863}, \"session_id\": {\"weight_norm\": 0.29669, \"weight\": 0.29669}}, \"type\": \"suit\"}, {\"sourceIndex\": 1, \"targetIndex\": 10, \"weights\": {\"event_id\": {\"weight_norm\": 0.70331, \"weight\": 0.70331}, \"user_id\": {\"weight_norm\": 0.81947, \"weight\": 0.81947}, \"session_id\": {\"weight_norm\": 0.70331, \"weight\": 0.70331}}, \"type\": \"suit\"}],\n",
       "    nodesColsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    linksWeightsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    nodesThreshold: {\"user_id\": 0.0, \"event_id\": 0.0},\n",
       "    linksThreshold: {\"user_id\": 0.0, \"event_id\": 0.0},\n",
       "    shownNodesCol: 'event_id',\n",
       "    shownLinksWeight: 'event_id',\n",
       "    selectedNodesColForThresholds: 'event_id',\n",
       "    selectedLinksWeightForThresholds: 'event_id',\n",
       "    showWeights: true,\n",
       "    showPercents: false,\n",
       "    showNodesNames: true,\n",
       "    showAllEdgesForTargets: true,\n",
       "    showNodesWithoutLinks: false,\n",
       "    showEdgesInfoOnHover: true,\n",
       "    useLayoutDump: Boolean(0),\n",
       "    weightTemplate: undefined,\n",
       "    trackingHWID: 'fdaa9a9e-9fe1-4593-b94c-0099fabe092e'\n",
       "})\n",
       "`\n",
       "        iframeDocument.body.appendChild(initGraph)\n",
       "      })\n",
       "\n",
       "      iframeDocument.head.appendChild(graphScript)\n",
       "      iframeDocument.body.dataset.templateId = 'elNGHFJE_template'\n",
       "\n",
       "      console.info('Graph IFRAME initialized')\n",
       "    }\n",
       "\n",
       "    console.log(`Graph IFRAME loaded: ` + iframeLoaded)\n",
       "\n",
       "    if (iframeLoaded) {\n",
       "      init()\n",
       "      return\n",
       "    }\n",
       "\n",
       "    iframe.onload = () => {\n",
       "      init()\n",
       "      window.reteLoadedIframes = window.reteLoadedIframes || []\n",
       "      window.reteLoadedIframes.push('elNGHFJE')\n",
       "    }\n",
       "  })()\n",
       "</script>\n",
       "\n",
       "<template id=\"elNGHFJE_template\">\n",
       "  <!DOCTYPE html>\n",
       "<html lang=\"en\">\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\"/>\n",
       "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>\n",
       "    <meta name=\"theme-color\" content=\"#000000\"/>\n",
       "    <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\"/>\n",
       "    <link crossorigin rel=\"preconnect\" href=\"https://fonts.gstatic.com\"/>\n",
       "    <link\n",
       "            crossorigin\n",
       "            href=\"https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap\"\n",
       "            rel=\"stylesheet\"\n",
       "    />\n",
       "    <title>Retentioneering Transition Graph Application</title>\n",
       "</head>\n",
       "\n",
       "<body>\n",
       "<noscript>You need to enable JavaScript to run this app.</noscript>\n",
       "<iframe id=\"el05PNN5\" src=\"about:blank\" width=\"960\" height=\"600\"\n",
       "  onload=\"window.reteLoadedIframes = window.reteLoadedIframes || []; window.reteLoadedIframes.push('el05PNN5')\">\n",
       "</iframe>\n",
       "<script>\n",
       "  // We render our widgets inside of iframes (to isolate javascript).\n",
       "  // The @jupyterlab/services library we use reads the basic URL parameters\n",
       "  // for the Jupyter Kernel Gateway and ws connections) from the DOM.\n",
       "  // These parameters are not present in the nested iframe.\n",
       "  // This function copies this configuration to the DOM of the current\n",
       "  // iframe so that PageConfig (https://github.com/jupyterlab/jupyterlab/blob/master/packages/coreutils/src/pageconfig.ts#L36) can retrieve them\n",
       "  function proxyNotebookEnv({ win, doc }) {\n",
       "    const topWindow = window.top\n",
       "\n",
       "    // For classic notebook\n",
       "    try {\n",
       "      const topBody = topWindow.document.body\n",
       "\n",
       "      for (const [name, val] of Object.entries(topBody.dataset)) {\n",
       "        doc.body.dataset[name] = val\n",
       "      }\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "\n",
       "    // Ror Jupyter lab\n",
       "    try {\n",
       "      if (doc.getElementById('jupyter-config-data')) {\n",
       "        return\n",
       "      }\n",
       "      const el = topWindow.document.getElementById('jupyter-config-data')\n",
       "\n",
       "      if (!el) {\n",
       "        return\n",
       "      }\n",
       "\n",
       "      const configData = el.textContent\n",
       "      const id = el.getAttribute('id')\n",
       "      const type = el.getAttribute('type')\n",
       "\n",
       "      const config = doc.createElement('script')\n",
       "      if (id) {\n",
       "        config.setAttribute('id', id)\n",
       "      }\n",
       "      if (type) {\n",
       "        config.setAttribute('type', type)\n",
       "      }\n",
       "      config.textContent = configData\n",
       "      doc.body.appendChild(config)\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function createDoctype({ doc }) {\n",
       "    const newDoctype = doc.implementation.createDocumentType('html', '', '')\n",
       "\n",
       "    if (!doc.doctype) {\n",
       "      doc.insertBefore(newDoctype, doc.childNodes[0])\n",
       "    }\n",
       "  }\n",
       "</script><script>\n",
       "  (function () {\n",
       "    console.info('Initialize graph IFRAME')\n",
       "\n",
       "    const iframe = document.getElementById('el05PNN5')\n",
       "    const iframeLoaded = window.reteLoadedIframes && window.reteLoadedIframes.includes('el05PNN5')\n",
       "\n",
       "    const init = () => {\n",
       "      console.info('Graph IFRAME loaded')\n",
       "\n",
       "      const iframeDocument = document.getElementById('el05PNN5').contentDocument\n",
       "      const iframeWindow = document.getElementById('el05PNN5').contentDocument\n",
       "\n",
       "      iframeDocument.body.innerHTML = '<div id=\"root\"></div>'\n",
       "\n",
       "      createDoctype({ doc: iframeDocument })\n",
       "      proxyNotebookEnv({ win: iframeWindow, doc: iframeDocument })\n",
       "\n",
       "      const graphScript = iframeDocument.createElement('script')\n",
       "\n",
       "      graphScript.src = `https://static.server.retentioneering.com/package/@rete/transition-graph/version/1/dist/transition-graph.umd.js?id=el0I7LXX`\n",
       "\n",
       "      graphScript.addEventListener('load', () => {\n",
       "        console.info('JavaScript library loaded')\n",
       "\n",
       "        const initGraph = iframeDocument.createElement('script')\n",
       "\n",
       "        initGraph.innerHTML = `\n",
       "    initialize({\n",
       "    serverId: 'b0b062e5-2263-40ad-aead-7a5dbd15278d',\n",
       "    env: 'classic',\n",
       "    kernelId: \"31facf3e-938d-4dc7-89f4-54fb5692cd63\",\n",
       "    selectedNormalizationTypeId: 'node',\n",
       "    configNodes: <%= nodes %>,\n",
       "    configLinks: <%= links %>,\n",
       "    nodesColsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    linksWeightsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    nodesThreshold: <%= nodes_threshold %>,\n",
       "    linksThreshold: <%= links_threshold %>,\n",
       "    shownNodesCol: '<%= shown_nodes_col %>',\n",
       "    shownLinksWeight: '<%= shown_links_weight %>',\n",
       "    selectedNodesColForThresholds: '<%= selected_nodes_col_for_thresholds %>',\n",
       "    selectedLinksWeightForThresholds: '<%= selected_links_weight_for_thresholds %>',\n",
       "    showWeights: <%= show_weights %>,\n",
       "    showPercents: <%= show_percents %>,\n",
       "    showNodesNames: <%= show_nodes_names %>,\n",
       "    showAllEdgesForTargets: <%= show_all_edges_for_targets %>,\n",
       "    showNodesWithoutLinks: <%= show_nodes_without_links %>,\n",
       "    showEdgesInfoOnHover: <%= show_edges_info_on_hover %>,\n",
       "    useLayoutDump: Boolean(1),\n",
       "    weightTemplate: undefined,\n",
       "    trackingHWID: 'fdaa9a9e-9fe1-4593-b94c-0099fabe092e'\n",
       "})\n",
       "`\n",
       "        iframeDocument.body.appendChild(initGraph)\n",
       "      })\n",
       "\n",
       "      iframeDocument.head.appendChild(graphScript)\n",
       "      iframeDocument.body.dataset.templateId = 'el05PNN5_template'\n",
       "\n",
       "      console.info('Graph IFRAME initialized')\n",
       "    }\n",
       "\n",
       "    console.log(`Graph IFRAME loaded: ` + iframeLoaded)\n",
       "\n",
       "    if (iframeLoaded) {\n",
       "      init()\n",
       "      return\n",
       "    }\n",
       "\n",
       "    iframe.onload = () => {\n",
       "      init()\n",
       "      window.reteLoadedIframes = window.reteLoadedIframes || []\n",
       "      window.reteLoadedIframes.push('el05PNN5')\n",
       "    }\n",
       "  })()\n",
       "</script>\n",
       "\n",
       "<template id=\"el05PNN5_template\">\n",
       "  \n",
       "</template>\n",
       "</body>\n",
       "</html>\n",
       "</template>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<retentioneering.tooling.transition_graph.transition_graph.TransitionGraph at 0x17f037c70>"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream_out = stream_7_nodes.collapse_loops(suffix='loop')\n",
    "stream_out.transition_graph(edges_norm_type='node')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 980
    },
    "executionInfo": {
     "elapsed": 3476,
     "status": "ok",
     "timestamp": 1682612103347,
     "user": {
      "displayName": "Julia Ostanina",
      "userId": "13687663492290466770"
     },
     "user_tz": -120
    },
    "id": "THGKp7-Ot5m3",
    "outputId": "2466920f-18d9-4e2d-bb36-3a3c0a3adbc9"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<iframe id=\"el7FR61R\" src=\"about:blank\" width=\"960\" height=\"600\"\n",
       "  onload=\"window.reteLoadedIframes = window.reteLoadedIframes || []; window.reteLoadedIframes.push('el7FR61R')\">\n",
       "</iframe>\n",
       "<script>\n",
       "  // We render our widgets inside of iframes (to isolate javascript).\n",
       "  // The @jupyterlab/services library we use reads the basic URL parameters\n",
       "  // for the Jupyter Kernel Gateway and ws connections) from the DOM.\n",
       "  // These parameters are not present in the nested iframe.\n",
       "  // This function copies this configuration to the DOM of the current\n",
       "  // iframe so that PageConfig (https://github.com/jupyterlab/jupyterlab/blob/master/packages/coreutils/src/pageconfig.ts#L36) can retrieve them\n",
       "  function proxyNotebookEnv({ win, doc }) {\n",
       "    const topWindow = window.top\n",
       "\n",
       "    // For classic notebook\n",
       "    try {\n",
       "      const topBody = topWindow.document.body\n",
       "\n",
       "      for (const [name, val] of Object.entries(topBody.dataset)) {\n",
       "        doc.body.dataset[name] = val\n",
       "      }\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "\n",
       "    // Ror Jupyter lab\n",
       "    try {\n",
       "      if (doc.getElementById('jupyter-config-data')) {\n",
       "        return\n",
       "      }\n",
       "      const el = topWindow.document.getElementById('jupyter-config-data')\n",
       "\n",
       "      if (!el) {\n",
       "        return\n",
       "      }\n",
       "\n",
       "      const configData = el.textContent\n",
       "      const id = el.getAttribute('id')\n",
       "      const type = el.getAttribute('type')\n",
       "\n",
       "      const config = doc.createElement('script')\n",
       "      if (id) {\n",
       "        config.setAttribute('id', id)\n",
       "      }\n",
       "      if (type) {\n",
       "        config.setAttribute('type', type)\n",
       "      }\n",
       "      config.textContent = configData\n",
       "      doc.body.appendChild(config)\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function createDoctype({ doc }) {\n",
       "    const newDoctype = doc.implementation.createDocumentType('html', '', '')\n",
       "\n",
       "    if (!doc.doctype) {\n",
       "      doc.insertBefore(newDoctype, doc.childNodes[0])\n",
       "    }\n",
       "  }\n",
       "</script><script>\n",
       "  (function () {\n",
       "    console.info('Initialize graph IFRAME')\n",
       "\n",
       "    const iframe = document.getElementById('el7FR61R')\n",
       "    const iframeLoaded = window.reteLoadedIframes && window.reteLoadedIframes.includes('el7FR61R')\n",
       "\n",
       "    const init = () => {\n",
       "      console.info('Graph IFRAME loaded')\n",
       "\n",
       "      const iframeDocument = document.getElementById('el7FR61R').contentDocument\n",
       "      const iframeWindow = document.getElementById('el7FR61R').contentDocument\n",
       "\n",
       "      iframeDocument.body.innerHTML = '<div id=\"root\"></div>'\n",
       "\n",
       "      createDoctype({ doc: iframeDocument })\n",
       "      proxyNotebookEnv({ win: iframeWindow, doc: iframeDocument })\n",
       "\n",
       "      const graphScript = iframeDocument.createElement('script')\n",
       "\n",
       "      graphScript.src = `https://static.server.retentioneering.com/package/@rete/transition-graph/version/1/dist/transition-graph.umd.js?id=elOMZQWX`\n",
       "\n",
       "      graphScript.addEventListener('load', () => {\n",
       "        console.info('JavaScript library loaded')\n",
       "\n",
       "        const initGraph = iframeDocument.createElement('script')\n",
       "\n",
       "        initGraph.innerHTML = `\n",
       "    initialize({\n",
       "    serverId: '114f673e-22e0-4c1e-aca4-a5eea270d388',\n",
       "    env: 'classic',\n",
       "    kernelId: \"31facf3e-938d-4dc7-89f4-54fb5692cd63\",\n",
       "    selectedNormalizationTypeId: 'none',\n",
       "    configNodes: [{\"index\": 0, \"name\": \"session_end\", \"degree\": {\"event_id\": {\"degree\": 34.0, \"source\": 4503}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 34.0, \"source\": 4503}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 1, \"name\": \"browsing_loop_6\", \"degree\": {\"event_id\": {\"degree\": 5.259160559626915, \"source\": 189}, \"user_id\": {\"degree\": 6.597847358121331, \"source\": 177}, \"session_id\": {\"degree\": 5.239173884077282, \"source\": 186}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 2, \"name\": \"path_start\", \"degree\": {\"event_id\": {\"degree\": 17.617588274483676, \"source\": 2044}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 17.617588274483676, \"source\": 2044}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 3, \"name\": \"browsing_loop_12\", \"degree\": {\"event_id\": {\"degree\": 4.0266489007328445, \"source\": 4}, \"user_id\": {\"degree\": 4.0587084148727985, \"source\": 4}, \"session_id\": {\"degree\": 4.0266489007328445, \"source\": 4}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 4, \"name\": \"browsing_loop_8\", \"degree\": {\"event_id\": {\"degree\": 4.299800133244504, \"source\": 45}, \"user_id\": {\"degree\": 4.660469667318982, \"source\": 45}, \"session_id\": {\"degree\": 4.299800133244504, \"source\": 45}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 5, \"name\": \"delivery_loop_2\", \"degree\": {\"event_id\": {\"degree\": 12.66755496335776, \"source\": 1301}, \"user_id\": {\"degree\": 20.159491193737768, \"source\": 1101}, \"session_id\": {\"degree\": 12.461025982678215, \"source\": 1270}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 6, \"name\": \"browsing_loop_4\", \"degree\": {\"event_id\": {\"degree\": 7.784143904063957, \"source\": 568}, \"user_id\": {\"degree\": 11.13307240704501, \"source\": 486}, \"session_id\": {\"degree\": 7.670886075949367, \"source\": 551}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 7, \"name\": \"browsing_loop_11\", \"degree\": {\"event_id\": {\"degree\": 4.0266489007328445, \"source\": 4}, \"user_id\": {\"degree\": 4.0587084148727985, \"source\": 4}, \"session_id\": {\"degree\": 4.0266489007328445, \"source\": 4}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 8, \"name\": \"browsing_loop_18\", \"degree\": {\"event_id\": {\"degree\": 4.006662225183211, \"source\": 1}, \"user_id\": {\"degree\": 4.014677103718199, \"source\": 1}, \"session_id\": {\"degree\": 4.006662225183211, \"source\": 1}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 9, \"name\": \"payment\", \"degree\": {\"event_id\": {\"degree\": 5.61892071952032, \"source\": 243}, \"user_id\": {\"degree\": 7.287671232876712, \"source\": 224}, \"session_id\": {\"degree\": 5.552298467688208, \"source\": 233}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 10, \"name\": \"session_start\", \"degree\": {\"event_id\": {\"degree\": 34.0, \"source\": 4503}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 34.0, \"source\": 4503}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 11, \"name\": \"browsing_loop_16\", \"degree\": {\"event_id\": {\"degree\": 4.006662225183211, \"source\": 1}, \"user_id\": {\"degree\": 4.014677103718199, \"source\": 1}, \"session_id\": {\"degree\": 4.006662225183211, \"source\": 1}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 12, \"name\": \"product1\", \"degree\": {\"event_id\": {\"degree\": 12.71419053964024, \"source\": 1308}, \"user_id\": {\"degree\": 17.51761252446184, \"source\": 921}, \"session_id\": {\"degree\": 11.328447701532312, \"source\": 1100}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 13, \"name\": \"browsing_loop_10\", \"degree\": {\"event_id\": {\"degree\": 4.0799467021985345, \"source\": 12}, \"user_id\": {\"degree\": 4.176125244618396, \"source\": 12}, \"session_id\": {\"degree\": 4.0799467021985345, \"source\": 12}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 14, \"name\": \"cart\", \"degree\": {\"event_id\": {\"degree\": 20.722185209860093, \"source\": 2510}, \"user_id\": {\"degree\": 27.498043052837573, \"source\": 1601}, \"session_id\": {\"degree\": 18.20386409060626, \"source\": 2132}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 15, \"name\": \"browsing_loop_9\", \"degree\": {\"event_id\": {\"degree\": 4.1865423051299135, \"source\": 28}, \"user_id\": {\"degree\": 4.410958904109589, \"source\": 28}, \"session_id\": {\"degree\": 4.1865423051299135, \"source\": 28}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 16, \"name\": \"payment_loop_3\", \"degree\": {\"event_id\": {\"degree\": 8.070619586942039, \"source\": 611}, \"user_id\": {\"degree\": 12.24853228962818, \"source\": 562}, \"session_id\": {\"degree\": 8.070619586942039, \"source\": 611}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 17, \"name\": \"browsing_loop_14\", \"degree\": {\"event_id\": {\"degree\": 4.006662225183211, \"source\": 1}, \"user_id\": {\"degree\": 4.014677103718199, \"source\": 1}, \"session_id\": {\"degree\": 4.006662225183211, \"source\": 1}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 18, \"name\": \"browsing_loop_2\", \"degree\": {\"event_id\": {\"degree\": 17.97068620919387, \"source\": 2097}, \"user_id\": {\"degree\": 21.788649706457925, \"source\": 1212}, \"session_id\": {\"degree\": 16.33177881412392, \"source\": 1851}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 19, \"name\": \"browsing_loop_5\", \"degree\": {\"event_id\": {\"degree\": 6.0652898067954695, \"source\": 310}, \"user_id\": {\"degree\": 8.271037181996086, \"source\": 291}, \"session_id\": {\"degree\": 6.038640906062625, \"source\": 306}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 20, \"name\": \"browsing_loop_13\", \"degree\": {\"event_id\": {\"degree\": 4.019986675549633, \"source\": 3}, \"user_id\": {\"degree\": 4.0440313111545985, \"source\": 3}, \"session_id\": {\"degree\": 4.019986675549633, \"source\": 3}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 21, \"name\": \"cart_loop_2\", \"degree\": {\"event_id\": {\"degree\": 4.006662225183211, \"source\": 1}, \"user_id\": {\"degree\": 4.014677103718199, \"source\": 1}, \"session_id\": {\"degree\": 4.006662225183211, \"source\": 1}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 22, \"name\": \"delivery\", \"degree\": {\"event_id\": {\"degree\": 5.932045303131246, \"source\": 290}, \"user_id\": {\"degree\": 7.977495107632095, \"source\": 271}, \"session_id\": {\"degree\": 5.878747501665556, \"source\": 282}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 23, \"name\": \"payment_loop_2\", \"degree\": {\"event_id\": {\"degree\": 5.638907395069953, \"source\": 246}, \"user_id\": {\"degree\": 7.522504892367905, \"source\": 240}, \"session_id\": {\"degree\": 5.638907395069953, \"source\": 246}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 24, \"name\": \"browsing\", \"degree\": {\"event_id\": {\"degree\": 22.64756828780813, \"source\": 2799}, \"user_id\": {\"degree\": 24.60665362035225, \"source\": 1404}, \"session_id\": {\"degree\": 18.5836109260493, \"source\": 2189}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 25, \"name\": \"product2\", \"degree\": {\"event_id\": {\"degree\": 16.671552298467688, \"source\": 1902}, \"user_id\": {\"degree\": 21.186888454011743, \"source\": 1171}, \"session_id\": {\"degree\": 13.726848767488342, \"source\": 1460}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 26, \"name\": \"browsing_loop_3\", \"degree\": {\"event_id\": {\"degree\": 10.635576282478347, \"source\": 996}, \"user_id\": {\"degree\": 15.345401174168298, \"source\": 773}, \"session_id\": {\"degree\": 10.202531645569621, \"source\": 931}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 27, \"name\": \"path_end\", \"degree\": {\"event_id\": {\"degree\": 17.617588274483676, \"source\": 2044}, \"user_id\": {\"degree\": 34.0, \"source\": 2044}, \"session_id\": {\"degree\": 17.617588274483676, \"source\": 2044}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}, {\"index\": 28, \"name\": \"browsing_loop_7\", \"degree\": {\"event_id\": {\"degree\": 4.586275816122585, \"source\": 88}, \"user_id\": {\"degree\": 5.247553816046967, \"source\": 85}, \"session_id\": {\"degree\": 4.586275816122585, \"source\": 88}}, \"type\": \"suit_node\", \"active\": true, \"alias\": false, \"parent\": null, \"changed_name\": null}],\n",
       "    configLinks: [{\"sourceIndex\": 24, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.21472143147620984, \"weight\": 528}, \"user_id\": {\"weight_norm\": 0.23140900195694716, \"weight\": 473}, \"session_id\": {\"weight_norm\": 0.2446183953033268, \"weight\": 500}}, \"type\": \"suit\"}, {\"sourceIndex\": 24, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.17974786498576656, \"weight\": 442}, \"user_id\": {\"weight_norm\": 0.1888454011741683, \"weight\": 386}, \"session_id\": {\"weight_norm\": 0.19667318982387474, \"weight\": 402}}, \"type\": \"suit\"}, {\"sourceIndex\": 24, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.2806018706791379, \"weight\": 690}, \"user_id\": {\"weight_norm\": 0.2700587084148728, \"weight\": 552}, \"session_id\": {\"weight_norm\": 0.2827788649706458, \"weight\": 578}}, \"type\": \"suit\"}, {\"sourceIndex\": 24, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.4631964213094754, \"weight\": 1139}, \"user_id\": {\"weight_norm\": 0.33317025440313114, \"weight\": 681}, \"session_id\": {\"weight_norm\": 0.5572407045009785, \"weight\": 1139}}, \"type\": \"suit\"}, {\"sourceIndex\": 13, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.0008133387555917039, \"weight\": 2}, \"user_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}, \"session_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}}, \"type\": \"suit\"}, {\"sourceIndex\": 13, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.0008133387555917039, \"weight\": 2}, \"user_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}, \"session_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}}, \"type\": \"suit\"}, {\"sourceIndex\": 13, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 13, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.0028466856445709637, \"weight\": 7}, \"user_id\": {\"weight_norm\": 0.003424657534246575, \"weight\": 7}, \"session_id\": {\"weight_norm\": 0.003424657534246575, \"weight\": 7}}, \"type\": \"suit\"}, {\"sourceIndex\": 7, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 7, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 7, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.0008133387555917039, \"weight\": 2}, \"user_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}, \"session_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}}, \"type\": \"suit\"}, {\"sourceIndex\": 3, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.0008133387555917039, \"weight\": 2}, \"user_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}, \"session_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}}, \"type\": \"suit\"}, {\"sourceIndex\": 3, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.0008133387555917039, \"weight\": 2}, \"user_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}, \"session_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}}, \"type\": \"suit\"}, {\"sourceIndex\": 20, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 20, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 20, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 17, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 11, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 8, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 18, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.18910126067507116, \"weight\": 465}, \"user_id\": {\"weight_norm\": 0.19765166340508805, \"weight\": 404}, \"session_id\": {\"weight_norm\": 0.22553816046966732, \"weight\": 461}}, \"type\": \"suit\"}, {\"sourceIndex\": 18, \"targetIndex\": 21, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 18, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.16836112240748272, \"weight\": 414}, \"user_id\": {\"weight_norm\": 0.18297455968688844, \"weight\": 374}, \"session_id\": {\"weight_norm\": 0.1952054794520548, \"weight\": 399}}, \"type\": \"suit\"}, {\"sourceIndex\": 18, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.24156161041073607, \"weight\": 594}, \"user_id\": {\"weight_norm\": 0.24266144814090018, \"weight\": 496}, \"session_id\": {\"weight_norm\": 0.2744618395303327, \"weight\": 561}}, \"type\": \"suit\"}, {\"sourceIndex\": 18, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.2533550223668158, \"weight\": 623}, \"user_id\": {\"weight_norm\": 0.24315068493150685, \"weight\": 497}, \"session_id\": {\"weight_norm\": 0.3047945205479452, \"weight\": 623}}, \"type\": \"suit\"}, {\"sourceIndex\": 26, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.09028060187067914, \"weight\": 222}, \"user_id\": {\"weight_norm\": 0.10371819960861056, \"weight\": 212}, \"session_id\": {\"weight_norm\": 0.10763209393346379, \"weight\": 220}}, \"type\": \"suit\"}, {\"sourceIndex\": 26, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.08174054493696625, \"weight\": 201}, \"user_id\": {\"weight_norm\": 0.09540117416829745, \"weight\": 195}, \"session_id\": {\"weight_norm\": 0.09735812133072407, \"weight\": 199}}, \"type\": \"suit\"}, {\"sourceIndex\": 26, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.11468076453843025, \"weight\": 282}, \"user_id\": {\"weight_norm\": 0.12524461839530332, \"weight\": 256}, \"session_id\": {\"weight_norm\": 0.13356164383561644, \"weight\": 273}}, \"type\": \"suit\"}, {\"sourceIndex\": 26, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.11834078893859293, \"weight\": 291}, \"user_id\": {\"weight_norm\": 0.12573385518591, \"weight\": 257}, \"session_id\": {\"weight_norm\": 0.1423679060665362, \"weight\": 291}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.04920699471329809, \"weight\": 121}, \"user_id\": {\"weight_norm\": 0.05821917808219178, \"weight\": 119}, \"session_id\": {\"weight_norm\": 0.059197651663405085, \"weight\": 121}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.044733631557543715, \"weight\": 110}, \"user_id\": {\"weight_norm\": 0.050880626223091974, \"weight\": 104}, \"session_id\": {\"weight_norm\": 0.053816046966731895, \"weight\": 110}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.06628710858072387, \"weight\": 163}, \"user_id\": {\"weight_norm\": 0.07778864970645792, \"weight\": 159}, \"session_id\": {\"weight_norm\": 0.07974559686888454, \"weight\": 163}}, \"type\": \"suit\"}, {\"sourceIndex\": 6, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.07076047173647824, \"weight\": 174}, \"user_id\": {\"weight_norm\": 0.0812133072407045, \"weight\": 166}, \"session_id\": {\"weight_norm\": 0.08512720156555773, \"weight\": 174}}, \"type\": \"suit\"}, {\"sourceIndex\": 19, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.028466856445709638, \"weight\": 70}, \"user_id\": {\"weight_norm\": 0.0337573385518591, \"weight\": 69}, \"session_id\": {\"weight_norm\": 0.03424657534246575, \"weight\": 70}}, \"type\": \"suit\"}, {\"sourceIndex\": 19, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.02887352582350549, \"weight\": 71}, \"user_id\": {\"weight_norm\": 0.034735812133072405, \"weight\": 71}, \"session_id\": {\"weight_norm\": 0.034735812133072405, \"weight\": 71}}, \"type\": \"suit\"}, {\"sourceIndex\": 19, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.032126880845872306, \"weight\": 79}, \"user_id\": {\"weight_norm\": 0.03767123287671233, \"weight\": 77}, \"session_id\": {\"weight_norm\": 0.038649706457925634, \"weight\": 79}}, \"type\": \"suit\"}, {\"sourceIndex\": 19, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.036600244001626675, \"weight\": 90}, \"user_id\": {\"weight_norm\": 0.043052837573385516, \"weight\": 88}, \"session_id\": {\"weight_norm\": 0.04403131115459882, \"weight\": 90}}, \"type\": \"suit\"}, {\"sourceIndex\": 1, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.017486783245221633, \"weight\": 43}, \"user_id\": {\"weight_norm\": 0.021037181996086105, \"weight\": 43}, \"session_id\": {\"weight_norm\": 0.021037181996086105, \"weight\": 43}}, \"type\": \"suit\"}, {\"sourceIndex\": 1, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.013826758845058967, \"weight\": 34}, \"user_id\": {\"weight_norm\": 0.016634050880626222, \"weight\": 34}, \"session_id\": {\"weight_norm\": 0.016634050880626222, \"weight\": 34}}, \"type\": \"suit\"}, {\"sourceIndex\": 1, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.01870679137860919, \"weight\": 46}, \"user_id\": {\"weight_norm\": 0.02201565557729941, \"weight\": 45}, \"session_id\": {\"weight_norm\": 0.022504892367906065, \"weight\": 46}}, \"type\": \"suit\"}, {\"sourceIndex\": 1, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.02684017893452623, \"weight\": 66}, \"user_id\": {\"weight_norm\": 0.03131115459882583, \"weight\": 64}, \"session_id\": {\"weight_norm\": 0.03228962818003914, \"weight\": 66}}, \"type\": \"suit\"}, {\"sourceIndex\": 28, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.0065067100447336315, \"weight\": 16}, \"user_id\": {\"weight_norm\": 0.007827788649706457, \"weight\": 16}, \"session_id\": {\"weight_norm\": 0.007827788649706457, \"weight\": 16}}, \"type\": \"suit\"}, {\"sourceIndex\": 28, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.0077267181781211875, \"weight\": 19}, \"user_id\": {\"weight_norm\": 0.009295499021526418, \"weight\": 19}, \"session_id\": {\"weight_norm\": 0.009295499021526418, \"weight\": 19}}, \"type\": \"suit\"}, {\"sourceIndex\": 28, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.008946726311508743, \"weight\": 22}, \"user_id\": {\"weight_norm\": 0.010763209393346379, \"weight\": 22}, \"session_id\": {\"weight_norm\": 0.010763209393346379, \"weight\": 22}}, \"type\": \"suit\"}, {\"sourceIndex\": 28, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.012606750711671411, \"weight\": 31}, \"user_id\": {\"weight_norm\": 0.015166340508806261, \"weight\": 31}, \"session_id\": {\"weight_norm\": 0.015166340508806261, \"weight\": 31}}, \"type\": \"suit\"}, {\"sourceIndex\": 4, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.004066693777958519, \"weight\": 10}, \"user_id\": {\"weight_norm\": 0.004892367906066536, \"weight\": 10}, \"session_id\": {\"weight_norm\": 0.004892367906066536, \"weight\": 10}}, \"type\": \"suit\"}, {\"sourceIndex\": 4, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.004066693777958519, \"weight\": 10}, \"user_id\": {\"weight_norm\": 0.004892367906066536, \"weight\": 10}, \"session_id\": {\"weight_norm\": 0.004892367906066536, \"weight\": 10}}, \"type\": \"suit\"}, {\"sourceIndex\": 4, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.004066693777958519, \"weight\": 10}, \"user_id\": {\"weight_norm\": 0.004892367906066536, \"weight\": 10}, \"session_id\": {\"weight_norm\": 0.004892367906066536, \"weight\": 10}}, \"type\": \"suit\"}, {\"sourceIndex\": 4, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.0061000406669377795, \"weight\": 15}, \"user_id\": {\"weight_norm\": 0.007338551859099804, \"weight\": 15}, \"session_id\": {\"weight_norm\": 0.007338551859099804, \"weight\": 15}}, \"type\": \"suit\"}, {\"sourceIndex\": 15, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.0020333468889792597, \"weight\": 5}, \"user_id\": {\"weight_norm\": 0.002446183953033268, \"weight\": 5}, \"session_id\": {\"weight_norm\": 0.002446183953033268, \"weight\": 5}}, \"type\": \"suit\"}, {\"sourceIndex\": 15, \"targetIndex\": 12, \"weights\": {\"event_id\": {\"weight_norm\": 0.0016266775111834079, \"weight\": 4}, \"user_id\": {\"weight_norm\": 0.0019569471624266144, \"weight\": 4}, \"session_id\": {\"weight_norm\": 0.0019569471624266144, \"weight\": 4}}, \"type\": \"suit\"}, {\"sourceIndex\": 15, \"targetIndex\": 25, \"weights\": {\"event_id\": {\"weight_norm\": 0.004473363155754371, \"weight\": 11}, \"user_id\": {\"weight_norm\": 0.0053816046966731895, \"weight\": 11}, \"session_id\": {\"weight_norm\": 0.0053816046966731895, \"weight\": 11}}, \"type\": \"suit\"}, {\"sourceIndex\": 15, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.0032533550223668157, \"weight\": 8}, \"user_id\": {\"weight_norm\": 0.003913894324853229, \"weight\": 8}, \"session_id\": {\"weight_norm\": 0.003913894324853229, \"weight\": 8}}, \"type\": \"suit\"}, {\"sourceIndex\": 14, \"targetIndex\": 24, \"weights\": {\"event_id\": {\"weight_norm\": 0.1134607564050427, \"weight\": 279}, \"user_id\": {\"weight_norm\": 0.11839530332681017, \"weight\": 242}, \"session_id\": {\"weight_norm\": 0.12524461839530332, \"weight\": 256}}, \"type\": \"suit\"}, {\"sourceIndex\": 14, \"targetIndex\": 18, \"weights\": {\"event_id\": {\"weight_norm\": 0.04839365595770639, \"weight\": 119}, \"user_id\": {\"weight_norm\": 0.05577299412915851, \"weight\": 114}, \"session_id\": {\"weight_norm\": 0.05626223091976516, \"weight\": 115}}, \"type\": \"suit\"}, {\"sourceIndex\": 14, \"targetIndex\": 26, \"weights\": {\"event_id\": {\"weight_norm\": 0.025620170801138674, \"weight\": 63}, \"user_id\": {\"weight_norm\": 0.030821917808219176, \"weight\": 63}, \"session_id\": {\"weight_norm\": 0.030821917808219176, \"weight\": 63}}, \"type\": \"suit\"}, {\"sourceIndex\": 14, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.009760065067100447, \"weight\": 24}, \"user_id\": {\"weight_norm\": 0.011741682974559686, \"weight\": 24}, \"session_id\": {\"weight_norm\": 0.011741682974559686, \"weight\": 24}}, \"type\": \"suit\"}, {\"sourceIndex\": 14, \"targetIndex\": 19, \"weights\": {\"event_id\": {\"weight_norm\": 0.008133387555917039, \"weight\": 20}, \"user_id\": {\"weight_norm\": 0.009784735812133072, \"weight\": 20}, \"session_id\": {\"weight_norm\": 0.009784735812133072, \"weight\": 20}}, \"type\": \"suit\"}, {\"sourceIndex\": 14, \"targetIndex\": 1, \"weights\": {\"event_id\": {\"weight_norm\": 0.0024400162667751117, \"weight\": 6}, \"user_id\": {\"weight_norm\": 0.0029354207436399216, \"weight\": 6}, \"session_id\": {\"weight_norm\": 0.0029354207436399216, \"weight\": 6}}, \"type\": \"suit\"}, {\"sourceIndex\": 14, \"targetIndex\": 28, \"weights\": {\"event_id\": {\"weight_norm\": 0.0020333468889792597, \"weight\": 5}, \"user_id\": {\"weight_norm\": 0.002446183953033268, \"weight\": 5}, \"session_id\": {\"weight_norm\": 0.002446183953033268, \"weight\": 5}}, \"type\": \"suit\"}, {\"sourceIndex\": 14, \"targetIndex\": 15, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 14, \"targetIndex\": 22, \"weights\": {\"event_id\": {\"weight_norm\": 0.11793411956079707, \"weight\": 290}, \"user_id\": {\"weight_norm\": 0.13258317025440314, \"weight\": 271}, \"session_id\": {\"weight_norm\": 0.1379647749510763, \"weight\": 282}}, \"type\": \"suit\"}, {\"sourceIndex\": 14, \"targetIndex\": 5, \"weights\": {\"event_id\": {\"weight_norm\": 0.5286701911346076, \"weight\": 1300}, \"user_id\": {\"weight_norm\": 0.5386497064579256, \"weight\": 1101}, \"session_id\": {\"weight_norm\": 0.6208414872798435, \"weight\": 1269}}, \"type\": \"suit\"}, {\"sourceIndex\": 14, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.16388775925172835, \"weight\": 403}, \"user_id\": {\"weight_norm\": 0.17416829745596868, \"weight\": 356}, \"session_id\": {\"weight_norm\": 0.1971624266144814, \"weight\": 403}}, \"type\": \"suit\"}, {\"sourceIndex\": 21, \"targetIndex\": 5, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 22, \"targetIndex\": 24, \"weights\": {\"event_id\": {\"weight_norm\": 0.036600244001626675, \"weight\": 90}, \"user_id\": {\"weight_norm\": 0.04207436399217221, \"weight\": 86}, \"session_id\": {\"weight_norm\": 0.04403131115459882, \"weight\": 90}}, \"type\": \"suit\"}, {\"sourceIndex\": 22, \"targetIndex\": 13, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 22, \"targetIndex\": 18, \"weights\": {\"event_id\": {\"weight_norm\": 0.010980073200488003, \"weight\": 27}, \"user_id\": {\"weight_norm\": 0.013209393346379647, \"weight\": 27}, \"session_id\": {\"weight_norm\": 0.013209393346379647, \"weight\": 27}}, \"type\": \"suit\"}, {\"sourceIndex\": 22, \"targetIndex\": 26, \"weights\": {\"event_id\": {\"weight_norm\": 0.0056933712891419274, \"weight\": 14}, \"user_id\": {\"weight_norm\": 0.00684931506849315, \"weight\": 14}, \"session_id\": {\"weight_norm\": 0.00684931506849315, \"weight\": 14}}, \"type\": \"suit\"}, {\"sourceIndex\": 22, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.0061000406669377795, \"weight\": 15}, \"user_id\": {\"weight_norm\": 0.007338551859099804, \"weight\": 15}, \"session_id\": {\"weight_norm\": 0.007338551859099804, \"weight\": 15}}, \"type\": \"suit\"}, {\"sourceIndex\": 22, \"targetIndex\": 19, \"weights\": {\"event_id\": {\"weight_norm\": 0.004066693777958519, \"weight\": 10}, \"user_id\": {\"weight_norm\": 0.004892367906066536, \"weight\": 10}, \"session_id\": {\"weight_norm\": 0.004892367906066536, \"weight\": 10}}, \"type\": \"suit\"}, {\"sourceIndex\": 22, \"targetIndex\": 1, \"weights\": {\"event_id\": {\"weight_norm\": 0.0020333468889792597, \"weight\": 5}, \"user_id\": {\"weight_norm\": 0.002446183953033268, \"weight\": 5}, \"session_id\": {\"weight_norm\": 0.002446183953033268, \"weight\": 5}}, \"type\": \"suit\"}, {\"sourceIndex\": 22, \"targetIndex\": 28, \"weights\": {\"event_id\": {\"weight_norm\": 0.0008133387555917039, \"weight\": 2}, \"user_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}, \"session_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}}, \"type\": \"suit\"}, {\"sourceIndex\": 22, \"targetIndex\": 4, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 22, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.0508336722244815, \"weight\": 125}, \"user_id\": {\"weight_norm\": 0.059197651663405085, \"weight\": 121}, \"session_id\": {\"weight_norm\": 0.0611545988258317, \"weight\": 125}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 9, \"weights\": {\"event_id\": {\"weight_norm\": 0.09882065880439203, \"weight\": 243}, \"user_id\": {\"weight_norm\": 0.1095890410958904, \"weight\": 224}, \"session_id\": {\"weight_norm\": 0.11399217221135029, \"weight\": 233}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 23, \"weights\": {\"event_id\": {\"weight_norm\": 0.10004066693777959, \"weight\": 246}, \"user_id\": {\"weight_norm\": 0.11741682974559686, \"weight\": 240}, \"session_id\": {\"weight_norm\": 0.12035225048923678, \"weight\": 246}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 16, \"weights\": {\"event_id\": {\"weight_norm\": 0.24847498983326555, \"weight\": 611}, \"user_id\": {\"weight_norm\": 0.27495107632093935, \"weight\": 562}, \"session_id\": {\"weight_norm\": 0.29892367906066536, \"weight\": 611}}, \"type\": \"suit\"}, {\"sourceIndex\": 5, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.08174054493696625, \"weight\": 201}, \"user_id\": {\"weight_norm\": 0.09393346379647749, \"weight\": 192}, \"session_id\": {\"weight_norm\": 0.09833659491193737, \"weight\": 201}}, \"type\": \"suit\"}, {\"sourceIndex\": 2, \"targetIndex\": 10, \"weights\": {\"event_id\": {\"weight_norm\": 0.8312322082147214, \"weight\": 2044}, \"user_id\": {\"weight_norm\": 1.0, \"weight\": 2044}, \"session_id\": {\"weight_norm\": 1.0, \"weight\": 2044}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 24, \"weights\": {\"event_id\": {\"weight_norm\": 0.024400162667751118, \"weight\": 60}, \"user_id\": {\"weight_norm\": 0.02837573385518591, \"weight\": 58}, \"session_id\": {\"weight_norm\": 0.02837573385518591, \"weight\": 58}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 18, \"weights\": {\"event_id\": {\"weight_norm\": 0.00854005693371289, \"weight\": 21}, \"user_id\": {\"weight_norm\": 0.009784735812133072, \"weight\": 20}, \"session_id\": {\"weight_norm\": 0.009784735812133072, \"weight\": 20}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 26, \"weights\": {\"event_id\": {\"weight_norm\": 0.0073200488003253355, \"weight\": 18}, \"user_id\": {\"weight_norm\": 0.008806262230919765, \"weight\": 18}, \"session_id\": {\"weight_norm\": 0.008806262230919765, \"weight\": 18}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.0024400162667751117, \"weight\": 6}, \"user_id\": {\"weight_norm\": 0.0029354207436399216, \"weight\": 6}, \"session_id\": {\"weight_norm\": 0.0029354207436399216, \"weight\": 6}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 19, \"weights\": {\"event_id\": {\"weight_norm\": 0.0016266775111834079, \"weight\": 4}, \"user_id\": {\"weight_norm\": 0.0019569471624266144, \"weight\": 4}, \"session_id\": {\"weight_norm\": 0.0019569471624266144, \"weight\": 4}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 1, \"weights\": {\"event_id\": {\"weight_norm\": 0.0016266775111834079, \"weight\": 4}, \"user_id\": {\"weight_norm\": 0.0019569471624266144, \"weight\": 4}, \"session_id\": {\"weight_norm\": 0.0019569471624266144, \"weight\": 4}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 15, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 9, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.05246034973566491, \"weight\": 129}, \"user_id\": {\"weight_norm\": 0.06262230919765166, \"weight\": 128}, \"session_id\": {\"weight_norm\": 0.06311154598825831, \"weight\": 129}}, \"type\": \"suit\"}, {\"sourceIndex\": 23, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.10004066693777959, \"weight\": 246}, \"user_id\": {\"weight_norm\": 0.11741682974559686, \"weight\": 240}, \"session_id\": {\"weight_norm\": 0.12035225048923678, \"weight\": 246}}, \"type\": \"suit\"}, {\"sourceIndex\": 16, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.24847498983326555, \"weight\": 611}, \"user_id\": {\"weight_norm\": 0.27495107632093935, \"weight\": 562}, \"session_id\": {\"weight_norm\": 0.29892367906066536, \"weight\": 611}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 24, \"weights\": {\"event_id\": {\"weight_norm\": 0.15250101667344448, \"weight\": 375}, \"user_id\": {\"weight_norm\": 0.15998043052837574, \"weight\": 327}, \"session_id\": {\"weight_norm\": 0.17123287671232876, \"weight\": 350}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 3, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 18, \"weights\": {\"event_id\": {\"weight_norm\": 0.05246034973566491, \"weight\": 129}, \"user_id\": {\"weight_norm\": 0.06017612524461839, \"weight\": 123}, \"session_id\": {\"weight_norm\": 0.060665362035225046, \"weight\": 124}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 26, \"weights\": {\"event_id\": {\"weight_norm\": 0.03294021960146401, \"weight\": 81}, \"user_id\": {\"weight_norm\": 0.03767123287671233, \"weight\": 77}, \"session_id\": {\"weight_norm\": 0.03767123287671233, \"weight\": 77}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.017893452623017485, \"weight\": 44}, \"user_id\": {\"weight_norm\": 0.021037181996086105, \"weight\": 43}, \"session_id\": {\"weight_norm\": 0.021526418786692758, \"weight\": 44}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 19, \"weights\": {\"event_id\": {\"weight_norm\": 0.012606750711671411, \"weight\": 31}, \"user_id\": {\"weight_norm\": 0.015166340508806261, \"weight\": 31}, \"session_id\": {\"weight_norm\": 0.015166340508806261, \"weight\": 31}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 1, \"weights\": {\"event_id\": {\"weight_norm\": 0.0028466856445709637, \"weight\": 7}, \"user_id\": {\"weight_norm\": 0.003424657534246575, \"weight\": 7}, \"session_id\": {\"weight_norm\": 0.003424657534246575, \"weight\": 7}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 28, \"weights\": {\"event_id\": {\"weight_norm\": 0.0012200081333875558, \"weight\": 3}, \"user_id\": {\"weight_norm\": 0.0014677103718199608, \"weight\": 3}, \"session_id\": {\"weight_norm\": 0.0014677103718199608, \"weight\": 3}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 4, \"weights\": {\"event_id\": {\"weight_norm\": 0.0008133387555917039, \"weight\": 2}, \"user_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}, \"session_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 15, \"weights\": {\"event_id\": {\"weight_norm\": 0.0012200081333875558, \"weight\": 3}, \"user_id\": {\"weight_norm\": 0.0014677103718199608, \"weight\": 3}, \"session_id\": {\"weight_norm\": 0.0014677103718199608, \"weight\": 3}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.1752745018300122, \"weight\": 431}, \"user_id\": {\"weight_norm\": 0.1908023483365949, \"weight\": 390}, \"session_id\": {\"weight_norm\": 0.2025440313111546, \"weight\": 414}}, \"type\": \"suit\"}, {\"sourceIndex\": 12, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.08174054493696625, \"weight\": 201}, \"user_id\": {\"weight_norm\": 0.09246575342465753, \"weight\": 189}, \"session_id\": {\"weight_norm\": 0.09833659491193737, \"weight\": 201}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 24, \"weights\": {\"event_id\": {\"weight_norm\": 0.26799511996746644, \"weight\": 659}, \"user_id\": {\"weight_norm\": 0.2534246575342466, \"weight\": 518}, \"session_id\": {\"weight_norm\": 0.28522504892367906, \"weight\": 583}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 13, \"weights\": {\"event_id\": {\"weight_norm\": 0.0008133387555917039, \"weight\": 2}, \"user_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}, \"session_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 7, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 20, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 18, \"weights\": {\"event_id\": {\"weight_norm\": 0.09434729564863766, \"weight\": 232}, \"user_id\": {\"weight_norm\": 0.10616438356164383, \"weight\": 217}, \"session_id\": {\"weight_norm\": 0.10812133072407044, \"weight\": 221}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 26, \"weights\": {\"event_id\": {\"weight_norm\": 0.05327368849125661, \"weight\": 131}, \"user_id\": {\"weight_norm\": 0.0611545988258317, \"weight\": 125}, \"session_id\": {\"weight_norm\": 0.06164383561643835, \"weight\": 126}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.027246848312322082, \"weight\": 67}, \"user_id\": {\"weight_norm\": 0.03131115459882583, \"weight\": 64}, \"session_id\": {\"weight_norm\": 0.03228962818003914, \"weight\": 66}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 19, \"weights\": {\"event_id\": {\"weight_norm\": 0.015046766978446523, \"weight\": 37}, \"user_id\": {\"weight_norm\": 0.018101761252446183, \"weight\": 37}, \"session_id\": {\"weight_norm\": 0.018101761252446183, \"weight\": 37}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 1, \"weights\": {\"event_id\": {\"weight_norm\": 0.009760065067100447, \"weight\": 24}, \"user_id\": {\"weight_norm\": 0.011252446183953033, \"weight\": 23}, \"session_id\": {\"weight_norm\": 0.011741682974559686, \"weight\": 24}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 28, \"weights\": {\"event_id\": {\"weight_norm\": 0.004880032533550223, \"weight\": 12}, \"user_id\": {\"weight_norm\": 0.005870841487279843, \"weight\": 12}, \"session_id\": {\"weight_norm\": 0.005870841487279843, \"weight\": 12}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 4, \"weights\": {\"event_id\": {\"weight_norm\": 0.0016266775111834079, \"weight\": 4}, \"user_id\": {\"weight_norm\": 0.0019569471624266144, \"weight\": 4}, \"session_id\": {\"weight_norm\": 0.0019569471624266144, \"weight\": 4}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 15, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 14, \"weights\": {\"event_id\": {\"weight_norm\": 0.24156161041073607, \"weight\": 594}, \"user_id\": {\"weight_norm\": 0.25244618395303325, \"weight\": 516}, \"session_id\": {\"weight_norm\": 0.27495107632093935, \"weight\": 562}}, \"type\": \"suit\"}, {\"sourceIndex\": 25, \"targetIndex\": 0, \"weights\": {\"event_id\": {\"weight_norm\": 0.055713704758031724, \"weight\": 137}, \"user_id\": {\"weight_norm\": 0.06506849315068493, \"weight\": 133}, \"session_id\": {\"weight_norm\": 0.06702544031311154, \"weight\": 137}}, \"type\": \"suit\"}, {\"sourceIndex\": 0, \"targetIndex\": 27, \"weights\": {\"event_id\": {\"weight_norm\": 0.8312322082147214, \"weight\": 2044}, \"user_id\": {\"weight_norm\": 1.0, \"weight\": 2044}, \"session_id\": {\"weight_norm\": 1.0, \"weight\": 2044}}, \"type\": \"suit\"}, {\"sourceIndex\": 0, \"targetIndex\": 10, \"weights\": {\"event_id\": {\"weight_norm\": 1.0, \"weight\": 2459}, \"user_id\": {\"weight_norm\": 0.5445205479452054, \"weight\": 1113}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 24, \"weights\": {\"event_id\": {\"weight_norm\": 0.5433102887352582, \"weight\": 1336}, \"user_id\": {\"weight_norm\": 0.4486301369863014, \"weight\": 917}, \"session_id\": {\"weight_norm\": 0.6536203522504892, \"weight\": 1336}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 13, \"weights\": {\"event_id\": {\"weight_norm\": 0.0036600244001626678, \"weight\": 9}, \"user_id\": {\"weight_norm\": 0.004403131115459882, \"weight\": 9}, \"session_id\": {\"weight_norm\": 0.004403131115459882, \"weight\": 9}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 7, \"weights\": {\"event_id\": {\"weight_norm\": 0.0012200081333875558, \"weight\": 3}, \"user_id\": {\"weight_norm\": 0.0014677103718199608, \"weight\": 3}, \"session_id\": {\"weight_norm\": 0.0014677103718199608, \"weight\": 3}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 3, \"weights\": {\"event_id\": {\"weight_norm\": 0.0012200081333875558, \"weight\": 3}, \"user_id\": {\"weight_norm\": 0.0014677103718199608, \"weight\": 3}, \"session_id\": {\"weight_norm\": 0.0014677103718199608, \"weight\": 3}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 20, \"weights\": {\"event_id\": {\"weight_norm\": 0.0008133387555917039, \"weight\": 2}, \"user_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}, \"session_id\": {\"weight_norm\": 0.0009784735812133072, \"weight\": 2}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 17, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 11, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 8, \"weights\": {\"event_id\": {\"weight_norm\": 0.00040666937779585197, \"weight\": 1}, \"user_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}, \"session_id\": {\"weight_norm\": 0.0004892367906066536, \"weight\": 1}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 18, \"weights\": {\"event_id\": {\"weight_norm\": 0.6380642537616917, \"weight\": 1569}, \"user_id\": {\"weight_norm\": 0.5019569471624267, \"weight\": 1026}, \"session_id\": {\"weight_norm\": 0.7676125244618396, \"weight\": 1569}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 26, \"weights\": {\"event_id\": {\"weight_norm\": 0.280195201301342, \"weight\": 689}, \"user_id\": {\"weight_norm\": 0.2788649706457926, \"weight\": 570}, \"session_id\": {\"weight_norm\": 0.33708414872798437, \"weight\": 689}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 6, \"weights\": {\"event_id\": {\"weight_norm\": 0.16754778365189102, \"weight\": 412}, \"user_id\": {\"weight_norm\": 0.1815068493150685, \"weight\": 371}, \"session_id\": {\"weight_norm\": 0.20156555772994128, \"weight\": 412}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 19, \"weights\": {\"event_id\": {\"weight_norm\": 0.0845872305815372, \"weight\": 208}, \"user_id\": {\"weight_norm\": 0.09686888454011741, \"weight\": 198}, \"session_id\": {\"weight_norm\": 0.10176125244618395, \"weight\": 208}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 1, \"weights\": {\"event_id\": {\"weight_norm\": 0.05815372102480683, \"weight\": 143}, \"user_id\": {\"weight_norm\": 0.0675146771037182, \"weight\": 138}, \"session_id\": {\"weight_norm\": 0.06996086105675146, \"weight\": 143}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 28, \"weights\": {\"event_id\": {\"weight_norm\": 0.02684017893452623, \"weight\": 66}, \"user_id\": {\"weight_norm\": 0.03131115459882583, \"weight\": 64}, \"session_id\": {\"weight_norm\": 0.03228962818003914, \"weight\": 66}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 4, \"weights\": {\"event_id\": {\"weight_norm\": 0.015453436356242375, \"weight\": 38}, \"user_id\": {\"weight_norm\": 0.018590998043052837, \"weight\": 38}, \"session_id\": {\"weight_norm\": 0.018590998043052837, \"weight\": 38}}, \"type\": \"suit\"}, {\"sourceIndex\": 10, \"targetIndex\": 15, \"weights\": {\"event_id\": {\"weight_norm\": 0.008946726311508743, \"weight\": 22}, \"user_id\": {\"weight_norm\": 0.010763209393346379, \"weight\": 22}, \"session_id\": {\"weight_norm\": 0.010763209393346379, \"weight\": 22}}, \"type\": \"suit\"}],\n",
       "    nodesColsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    linksWeightsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    nodesThreshold: {\"user_id\": 0.0, \"event_id\": 0.0},\n",
       "    linksThreshold: {\"user_id\": 0.0, \"event_id\": 0.0},\n",
       "    shownNodesCol: 'event_id',\n",
       "    shownLinksWeight: 'event_id',\n",
       "    selectedNodesColForThresholds: 'event_id',\n",
       "    selectedLinksWeightForThresholds: 'event_id',\n",
       "    showWeights: true,\n",
       "    showPercents: false,\n",
       "    showNodesNames: true,\n",
       "    showAllEdgesForTargets: true,\n",
       "    showNodesWithoutLinks: false,\n",
       "    showEdgesInfoOnHover: true,\n",
       "    useLayoutDump: Boolean(0),\n",
       "    weightTemplate: undefined,\n",
       "    trackingHWID: 'fdaa9a9e-9fe1-4593-b94c-0099fabe092e'\n",
       "})\n",
       "`\n",
       "        iframeDocument.body.appendChild(initGraph)\n",
       "      })\n",
       "\n",
       "      iframeDocument.head.appendChild(graphScript)\n",
       "      iframeDocument.body.dataset.templateId = 'el7FR61R_template'\n",
       "\n",
       "      console.info('Graph IFRAME initialized')\n",
       "    }\n",
       "\n",
       "    console.log(`Graph IFRAME loaded: ` + iframeLoaded)\n",
       "\n",
       "    if (iframeLoaded) {\n",
       "      init()\n",
       "      return\n",
       "    }\n",
       "\n",
       "    iframe.onload = () => {\n",
       "      init()\n",
       "      window.reteLoadedIframes = window.reteLoadedIframes || []\n",
       "      window.reteLoadedIframes.push('el7FR61R')\n",
       "    }\n",
       "  })()\n",
       "</script>\n",
       "\n",
       "<template id=\"el7FR61R_template\">\n",
       "  <!DOCTYPE html>\n",
       "<html lang=\"en\">\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\"/>\n",
       "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>\n",
       "    <meta name=\"theme-color\" content=\"#000000\"/>\n",
       "    <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\"/>\n",
       "    <link crossorigin rel=\"preconnect\" href=\"https://fonts.gstatic.com\"/>\n",
       "    <link\n",
       "            crossorigin\n",
       "            href=\"https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap\"\n",
       "            rel=\"stylesheet\"\n",
       "    />\n",
       "    <title>Retentioneering Transition Graph Application</title>\n",
       "</head>\n",
       "\n",
       "<body>\n",
       "<noscript>You need to enable JavaScript to run this app.</noscript>\n",
       "<iframe id=\"elE0U99P\" src=\"about:blank\" width=\"960\" height=\"600\"\n",
       "  onload=\"window.reteLoadedIframes = window.reteLoadedIframes || []; window.reteLoadedIframes.push('elE0U99P')\">\n",
       "</iframe>\n",
       "<script>\n",
       "  // We render our widgets inside of iframes (to isolate javascript).\n",
       "  // The @jupyterlab/services library we use reads the basic URL parameters\n",
       "  // for the Jupyter Kernel Gateway and ws connections) from the DOM.\n",
       "  // These parameters are not present in the nested iframe.\n",
       "  // This function copies this configuration to the DOM of the current\n",
       "  // iframe so that PageConfig (https://github.com/jupyterlab/jupyterlab/blob/master/packages/coreutils/src/pageconfig.ts#L36) can retrieve them\n",
       "  function proxyNotebookEnv({ win, doc }) {\n",
       "    const topWindow = window.top\n",
       "\n",
       "    // For classic notebook\n",
       "    try {\n",
       "      const topBody = topWindow.document.body\n",
       "\n",
       "      for (const [name, val] of Object.entries(topBody.dataset)) {\n",
       "        doc.body.dataset[name] = val\n",
       "      }\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "\n",
       "    // Ror Jupyter lab\n",
       "    try {\n",
       "      if (doc.getElementById('jupyter-config-data')) {\n",
       "        return\n",
       "      }\n",
       "      const el = topWindow.document.getElementById('jupyter-config-data')\n",
       "\n",
       "      if (!el) {\n",
       "        return\n",
       "      }\n",
       "\n",
       "      const configData = el.textContent\n",
       "      const id = el.getAttribute('id')\n",
       "      const type = el.getAttribute('type')\n",
       "\n",
       "      const config = doc.createElement('script')\n",
       "      if (id) {\n",
       "        config.setAttribute('id', id)\n",
       "      }\n",
       "      if (type) {\n",
       "        config.setAttribute('type', type)\n",
       "      }\n",
       "      config.textContent = configData\n",
       "      doc.body.appendChild(config)\n",
       "    } catch (error) {\n",
       "      console.error(error)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function createDoctype({ doc }) {\n",
       "    const newDoctype = doc.implementation.createDocumentType('html', '', '')\n",
       "\n",
       "    if (!doc.doctype) {\n",
       "      doc.insertBefore(newDoctype, doc.childNodes[0])\n",
       "    }\n",
       "  }\n",
       "</script><script>\n",
       "  (function () {\n",
       "    console.info('Initialize graph IFRAME')\n",
       "\n",
       "    const iframe = document.getElementById('elE0U99P')\n",
       "    const iframeLoaded = window.reteLoadedIframes && window.reteLoadedIframes.includes('elE0U99P')\n",
       "\n",
       "    const init = () => {\n",
       "      console.info('Graph IFRAME loaded')\n",
       "\n",
       "      const iframeDocument = document.getElementById('elE0U99P').contentDocument\n",
       "      const iframeWindow = document.getElementById('elE0U99P').contentDocument\n",
       "\n",
       "      iframeDocument.body.innerHTML = '<div id=\"root\"></div>'\n",
       "\n",
       "      createDoctype({ doc: iframeDocument })\n",
       "      proxyNotebookEnv({ win: iframeWindow, doc: iframeDocument })\n",
       "\n",
       "      const graphScript = iframeDocument.createElement('script')\n",
       "\n",
       "      graphScript.src = `https://static.server.retentioneering.com/package/@rete/transition-graph/version/1/dist/transition-graph.umd.js?id=elOMZQWX`\n",
       "\n",
       "      graphScript.addEventListener('load', () => {\n",
       "        console.info('JavaScript library loaded')\n",
       "\n",
       "        const initGraph = iframeDocument.createElement('script')\n",
       "\n",
       "        initGraph.innerHTML = `\n",
       "    initialize({\n",
       "    serverId: '114f673e-22e0-4c1e-aca4-a5eea270d388',\n",
       "    env: 'classic',\n",
       "    kernelId: \"31facf3e-938d-4dc7-89f4-54fb5692cd63\",\n",
       "    selectedNormalizationTypeId: 'none',\n",
       "    configNodes: <%= nodes %>,\n",
       "    configLinks: <%= links %>,\n",
       "    nodesColsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    linksWeightsNames: ['event_id', 'event_id', 'user_id', 'session_id'],\n",
       "    nodesThreshold: <%= nodes_threshold %>,\n",
       "    linksThreshold: <%= links_threshold %>,\n",
       "    shownNodesCol: '<%= shown_nodes_col %>',\n",
       "    shownLinksWeight: '<%= shown_links_weight %>',\n",
       "    selectedNodesColForThresholds: '<%= selected_nodes_col_for_thresholds %>',\n",
       "    selectedLinksWeightForThresholds: '<%= selected_links_weight_for_thresholds %>',\n",
       "    showWeights: <%= show_weights %>,\n",
       "    showPercents: <%= show_percents %>,\n",
       "    showNodesNames: <%= show_nodes_names %>,\n",
       "    showAllEdgesForTargets: <%= show_all_edges_for_targets %>,\n",
       "    showNodesWithoutLinks: <%= show_nodes_without_links %>,\n",
       "    showEdgesInfoOnHover: <%= show_edges_info_on_hover %>,\n",
       "    useLayoutDump: Boolean(1),\n",
       "    weightTemplate: undefined,\n",
       "    trackingHWID: 'fdaa9a9e-9fe1-4593-b94c-0099fabe092e'\n",
       "})\n",
       "`\n",
       "        iframeDocument.body.appendChild(initGraph)\n",
       "      })\n",
       "\n",
       "      iframeDocument.head.appendChild(graphScript)\n",
       "      iframeDocument.body.dataset.templateId = 'elE0U99P_template'\n",
       "\n",
       "      console.info('Graph IFRAME initialized')\n",
       "    }\n",
       "\n",
       "    console.log(`Graph IFRAME loaded: ` + iframeLoaded)\n",
       "\n",
       "    if (iframeLoaded) {\n",
       "      init()\n",
       "      return\n",
       "    }\n",
       "\n",
       "    iframe.onload = () => {\n",
       "      init()\n",
       "      window.reteLoadedIframes = window.reteLoadedIframes || []\n",
       "      window.reteLoadedIframes.push('elE0U99P')\n",
       "    }\n",
       "  })()\n",
       "</script>\n",
       "\n",
       "<template id=\"elE0U99P_template\">\n",
       "  \n",
       "</template>\n",
       "</body>\n",
       "</html>\n",
       "</template>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "stream_out = stream_7_nodes.collapse_loops(suffix='count')\n",
    "stream_out.transition_graph();"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "provenance": [],
   "toc_visible": true
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.15"
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
