{"id":326096,"date":"2021-07-07T15:00:27","date_gmt":"2021-07-07T15:00:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=326096"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=326096","title":{"rendered":"\u0414\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u0421\u044d\u043d\u043a\u0435\u0439 (Sankey diagram) \u043d\u0430 Python"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Aliradar. \u041c\u044b \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u0425\u0430\u0431\u0440\u0435, \u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u0434\u043d\u0430\u043a\u043e\u043f\u0438\u043b\u0441\u044f \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f. \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u043c\u0435\u043d\u044f \u0441\u043f\u043e\u0434\u0432\u0438\u0433\u043b\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0433\u043e\u0434\u043d\u044b\u0445 \u0433\u0430\u0439\u0434\u043e\u0432 \u043f\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0421\u044d\u043d\u043a\u0435\u0439 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c python \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435.<\/p>\n<p>\u0412 \u043c\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u043a\u043e\u043d\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0435\u0448\u0430\u043b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u043e &#8212; \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0443 \u043d\u0430\u0441 \u043c\u043d\u043e\u0433\u043e, \u0442\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e &#8212; \u0442\u0440\u0443\u0434\u043d\u0430\u044f \u0438 \u0434\u043e\u0440\u043e\u0433\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443 \u0421\u044d\u043d\u043a\u0435\u0439 (Sankey diagram).<\/p>\n<p>\u0417\u0430\u0431\u0435\u0433\u0430\u044f \u0432\u043f\u0435\u0440\u0435\u0434, \u043f\u043e\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f <a href=\"https:\/\/chart-studio.plotly.com\/~serega_408\/1.embed\" rel=\"noopener noreferrer nofollow\">\u0432 \u0438\u0442\u043e\u0433\u0435<\/a>. \u0414\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b python, pandas \u0438 plotly. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 <a href=\"https:\/\/colab.research.google.com\/github\/rusantsovsv\/senkey_tutorial\/blob\/main\/senkey_colab.ipynb\" rel=\"noopener noreferrer nofollow\">colab<\/a>, \u043b\u0438\u0431\u043e \u0432\u0437\u044f\u0442\u044c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 <a href=\"https:\/\/github.com\/rusantsovsv\/senkey_tutorial\" rel=\"noopener noreferrer nofollow\">github<\/a>.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e.<\/p>\n<h2>\u0427\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435?<\/h2>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u044d\u0442\u043e\u0439 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b <a href=\"https:\/\/en.wikipedia.org\/wiki\/Sankey_diagram\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432 1898 \u0433\u043e\u0434\u0443<\/a>. \u0415\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c, \u041c\u044d\u0442\u044c\u044e \u0421\u0435\u043d\u043a\u0435\u0439 (Matthew H. Sankey), \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f \u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f \u0431\u0435\u0437 \u044d\u043d\u0435\u0440\u0433\u043e\u043f\u043e\u0442\u0435\u0440\u044c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad0\/9cb\/187\/ad09cb1877a7314768bf9af7afd4658f.png\" alt=\"\u0422\u0435\u043f\u043b\u043e\u0432\u0430\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0430\u0440\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f\" title=\"\u0422\u0435\u043f\u043b\u043e\u0432\u0430\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0430\u0440\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f\" width=\"1024\" height=\"1088\"><figcaption>\u0422\u0435\u043f\u043b\u043e\u0432\u0430\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0430\u0440\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f<\/figcaption><\/figure>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u0421\u044d\u043d\u043a\u0435\u0439 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 &#8212; \u044d\u0442\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u0412\u043e\u0442 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430, \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2f6\/e48\/da1\/2f6e48da122e3bcbdc84e9dc770fcb9c.png\" alt=\"\u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0421\u044d\u043d\u043a\u0435\u0439\" title=\"\u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0421\u044d\u043d\u043a\u0435\u0439\" width=\"1039\" height=\"680\"><figcaption>\u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0421\u044d\u043d\u043a\u0435\u0439<\/figcaption><\/figure>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u044d\u0442\u0443 \u0441\u0445\u0435\u043c\u0443:<\/p>\n<ul>\n<li>\n<p>\u0435\u0441\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 event_1, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u043d\u044c\u0448\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0435\u0432\u0435\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0430 \u0441\u0445\u0435\u043c\u0435. \u0422\u0430\u043a\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c (source);<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 &#171;\u043f\u0435\u0440\u0435\u0445\u043e\u0434&#187; \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u0442 event_1 (source) \u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c event_1, event_2, event_3, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0448\u0430\u0433\u0435 (step_1) \u0446\u0435\u043b\u0435\u0432\u044b\u043c\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438 (target). \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0432\u0448\u0438\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442 source \u043a target \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0438\u0440\u0438\u043d\u044b \u043a\u0430\u043d\u0430\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 source \u0438 target;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430 \u0448\u0430\u0433\u0435 step_2 \u0443\u0436\u0435 event_1, event_2, event_3 \u0431\u0443\u0434\u0443\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438, \u0430 event_3 \u0438 event_4 \u0446\u0435\u043b\u0435\u0432\u044b\u043c\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442 \u0448\u0430\u0433\u0430 \u043a \u0448\u0430\u0433\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f source \u043d\u0430 target. \u0421\u0430\u043c\u043e\u0435 \u043f\u0435\u0440\u0432\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 &#8212; \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e source, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 &#8212; \u044d\u0442\u043e target, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 source \u043d\u0435\u0442 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0430 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0442\u0430\u0440\u0433\u0435\u0442\u0430 \u043d\u0435\u0442 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u0430 \u0441\u0445\u0435\u043c\u0430 &#8212; \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 \u043d\u0435\u0439 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 source, \u0438 \u043e\u0434\u0438\u043d \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 target. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438 source \u0438 target \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435, \u043a\u0430\u043a \u0438 \u0441\u0430\u043c\u0438\u0445 \u0448\u0430\u0433\u043e\u0432, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e.<\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. <\/p>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">PATH_TO_CSV = 'https:\/\/raw.githubusercontent.com\/rusantsovsv\/senkey_tutorial\/main\/csv\/senkey_data_tutorial.csv'  # \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a table = pd.read_csv(PATH_TO_CSV) table.head()<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf7\/fe6\/da8\/bf7fe6da849223ead9b18d56aaefba3c.png\" width=\"640\" height=\"181\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<ul>\n<li>\n<p>user_id &#8212; \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f;<\/p>\n<\/li>\n<li>\n<p>event_timestamp &#8212; \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>event_name &#8212; \u0438\u043c\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0430\u0440\u044b source-target, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u0430\u0440\u044b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f &#8212; \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0448\u0430\u0433 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def add_features(df):          \"\"\"\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0434\u043b\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b      Args:         df (pd.DataFrame): \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430.     Returns:         pd.DataFrame: \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438.     \"\"\"          # \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e id \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438     sorted_df = df.sort_values(by=['user_id', 'event_timestamp']).copy()     # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0448\u0430\u0433\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439     sorted_df['step'] = sorted_df.groupby('user_id').cumcount() + 1          # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u0437\u043b\u044b-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0438 \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0443\u0437\u043b\u044b     # \u0443\u0437\u043b\u044b-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 - \u044d\u0442\u043e \u0441\u0430\u043c\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f     sorted_df['source'] = sorted_df['event_name']     # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0443\u0437\u043b\u044b     sorted_df['target'] = sorted_df.groupby('user_id')['source'].shift(-1)          # \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0435\u0437 \u0438\u043c\u0435\u043d\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439     return sorted_df.drop(['event_name'], axis=1)    # \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 table = add_features(table) table.head()<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3d2\/d6e\/e99\/3d2d6ee9916ef5c1269c86e45650dca7.png\" width=\"839\" height=\"174\"><figcaption><\/figcaption><\/figure>\n<p>\u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e id \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043f\u0430\u0440\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u0439 source &#8212; target;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0448\u0430\u0433 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0434\u0430\u043b\u0435\u043d \u0441\u0442\u043e\u043b\u0431\u0435\u0446 event_name, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0448\u0430\u0433\u043e\u0432 \u043d\u0430 \u043d\u0430\u0448\u0435\u0439 \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0435. \u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0448\u0430\u0433\u043e\u0432, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043e, \u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0448\u0430\u0433\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0432\u043d\u044b\u043c 7.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0448\u0430\u0433\u043e\u0432 \u0434\u043e 7<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\"># \u0443\u0434\u0430\u043b\u0438\u043c \u0432\u0441\u0435 \u043f\u0430\u0440\u044b source-target, \u0448\u0430\u0433 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 7 # \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e df_comp = table[table['step'] &lt;= 7].copy().reset_index(drop=True)<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f source<\/h2>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0432 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f source. \u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435 target \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f source, \u0438 \u0447\u0442\u043e\u0431\u044b \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u043a\u043e\u0440\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0443\u0436\u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f source \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u043b\u044e\u0447\u0438 &#8212; \u044d\u0442\u043e \u0448\u0430\u0433\u0438, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f &#8212; \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 source \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.&nbsp;\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b source \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044e, \u0430 \u043d\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0441 0, \u043f\u0440\u0438 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0448\u0430\u0433\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0438\u043c\u0435\u043d\u0430 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c. \u0412\u0441\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u043a, \u043f\u043e\u0434\u043f\u0438\u0441\u0435\u0439 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 source \u0438 target.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 source<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def get_source_index(df):          \"\"\"\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 source      Args:         df (pd.DataFrame): \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 step, source, target.     Returns:         dict: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438, \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0438\u044f\u043c\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438\u043c\u0435\u043d\u0430\u043c source.     \"\"\"          res_dict = {}          count = 0     # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432     for no, step in enumerate(df['step'].unique().tolist()):         # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0448\u0430\u0433\u0430         res_dict[no+1] = {}         res_dict[no+1]['sources'] = df[df['step'] == step]['source'].unique().tolist()         res_dict[no+1]['sources_index'] = []         for i in range(len(res_dict[no+1]['sources'])):             res_dict[no+1]['sources_index'].append(count)             count += 1                  # \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043c \u0441\u043f\u0438\u0441\u043a\u0438     for key in res_dict:         res_dict[key]['sources_dict'] = {}         for name, no in zip(res_dict[key]['sources'], res_dict[key]['sources_index']):             res_dict[key]['sources_dict'][name] = no     return res_dict     # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c source_indexes = get_source_index(df_comp)<\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u0434\u043b\u044f \u0448\u0430\u0433\u0430 2<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">sources  ['history_opened', 'app_opened_from_market', 'sales_category_selected', 'favorites_opened', 'item_opened', 'app_opened_via_icon', 'market_opened_without_referral', 'price_history_opened', 'search_tab_opened', 'seller_info_opened', 'item_loaded_from_store', 'marketApp_opened', 'chart_click', 'item_opened_from_history', 'similar_tab_opened', 'reviews_tab_opened', 'app_remove', 'similar_item_opened', 'marketApp_opened_from_item', 'sales_item_opened_from_main', 'auth_opened', 'search_request_entered', 'item_info_click', 'sales_opened', 'settings_opened', 'similars_not_fetched_from_server', 'auth_user_succeeded', 'search_results_loaded']   sources_index  [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]   sources_dict  {'history_opened': 20, 'app_opened_from_market': 21, 'sales_category_selected': 22, 'favorites_opened': 23, 'item_opened': 24, 'app_opened_via_icon': 25, 'market_opened_without_referral': 26, 'price_history_opened': 27, 'search_tab_opened': 28, 'seller_info_opened': 29, 'item_loaded_from_store': 30, 'marketApp_opened': 31, 'chart_click': 32, 'item_opened_from_history': 33, 'similar_tab_opened': 34, 'reviews_tab_opened': 35, 'app_remove': 36, 'similar_item_opened': 37, 'marketApp_opened_from_item': 38, 'sales_item_opened_from_main': 39, 'auth_opened': 40, 'search_request_entered': 41, 'item_info_click': 42, 'sales_opened': 43, 'settings_opened': 44, 'similars_not_fetched_from_server': 45, 'auth_user_succeeded': 46, 'search_results_loaded': 47}<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432 \u0434\u043b\u044f source<\/h2>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0443\u043a\u0440\u0430\u0441\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 source-target \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430. \u042f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b 2 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 &#8212; \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438 \u0440\u0443\u0447\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u0446\u0432\u0435\u0442\u043e\u0432. <\/p>\n<p>\u0426\u0432\u0435\u0442\u0430 \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0432 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 RGBA. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043d\u0430\u043b\u044b source-target \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c\u0438, \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a \u0431\u043b\u043e\u043a\u0430\u043c \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u0441\u0445\u0435\u043c\u044b.<\/p>\n<p>\u0426\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f source:color. \u041f\u043e \u043b\u0438\u0447\u043d\u043e\u043c\u0443 \u0441\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u0431\u0440\u0430\u043b \u0442\u0435 \u0446\u0432\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043d\u0430 \u0431\u0435\u043b\u043e\u043c \u0444\u043e\u043d\u0435. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c, \u0443\u043a\u0430\u0437\u0430\u0432 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 colors_for_sources \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 mode=&#8217;custom&#8217; (&#8216;random&#8217; \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0432\u0435\u0442\u0430).<\/p>\n<details class=\"spoiler\">\n<summary>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0432\u0435\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def generate_random_color():          \"\"\"\u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432 rgba      Args:              Returns:         str: \u0421\u0442\u0440\u043e\u043a\u0430 \u0441\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0446\u0432\u0435\u0442\u0430     \"\"\"          # \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430     r, g, b = np.random.randint(255, size=3)     return f'rgba({r}, {g}, {b}, 1)'<\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f\u043c\u0438 source: color<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def colors_for_sources(mode):          \"\"\"\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432 rgba      Args:         mode (str): \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430, \u0435\u0441\u043b\u0438 'random', \u0430 \u0435\u0441\u043b\u0438 'custom' -                      \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435     Returns:         dict: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0446\u0432\u0435\u0442\u0430\u043c\u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443     \"\"\"     # \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043b\u043e\u0436\u0438\u043c \u0446\u0432\u0435\u0442\u0430 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c     colors_dict = {}          if mode == 'random':         # \u0433\u0435\u043d\u0435\u0440\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430         for label in df_comp['source'].unique():             r, g, b = np.random.randint(255, size=3)                         colors_dict[label] = f'rgba({r}, {g}, {b}, 1)'                  elif mode == 'custom':         # \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430         colors = requests.get('https:\/\/raw.githubusercontent.com\/rusantsovsv\/senkey_tutorial\/main\/json\/colors_senkey.json').json()         for no, label in enumerate(df_comp['source'].unique()):             colors_dict[label] = colors['custom_colors'][no]                  return colors_dict       # \u0433\u0435\u043d\u0435\u0440\u044e \u0446\u0432\u0435\u0442\u0430 \u0438\u0437 \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 colors_dict = colors_for_sources(mode='custom')<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/h2>\n<p>\u0414\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Plotly. \u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 (\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u043e\u0439) \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043d\u0443\u0436\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<ul>\n<li>\n<p>sources &#8212; \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 source;<\/p>\n<\/li>\n<li>\n<p>targets &#8212; \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 target;<\/p>\n<\/li>\n<li>\n<p>values &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0432\u0448\u0438\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438 source-target (&#171;\u043e\u0431\u044a\u0435\u043c&#187; \u043f\u043e\u0442\u043e\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438);<\/p>\n<\/li>\n<li>\n<p>labels &#8212; \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0443\u0437\u043b\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>colors_labels &#8212; \u0446\u0432\u0435\u0442 \u0443\u0437\u043b\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>link_color &#8212; \u0446\u0432\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>link_text &#8212; \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 2 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u044d\u0442\u0438\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432:<\/p>\n<details class=\"spoiler\">\n<summary>\u0420\u0430\u0441\u0447\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def percent_users(sources, targets, values):          \"\"\"     \u0420\u0430\u0441\u0447\u0435\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 id \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 (\u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 hover text \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430)          Args:         sources (list): \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 source.         targets (list): \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 target.         values (list): \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \"\u043e\u0431\u044a\u0435\u043c\u0430\u043c\u0438\" \u043f\u043e\u0442\u043e\u043a\u043e\u0432.              Returns:         list: \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \"\u043e\u0431\u044a\u0435\u043c\u0430\u043c\u0438\" \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445     \"\"\"          # \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0438 \u043c\u0435\u0442\u043a\u0438 \u0438 \u043d\u0430\u0439\u0434\u0435\u043c \u043f\u0430\u0440\u044b     zip_lists = list(zip(sources, targets, values))          new_list = []          # \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u043e\u0431\u0449\u0438\u043c \u043e\u0431\u044a\u0435\u043c\u043e\u043c \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0432 \u0443\u0437\u043b\u0430\u0445     unique_dict = {}          # \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0443\u0437\u043b\u0443     for source, target, value in zip_lists:         if source not in unique_dict:             # \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0432\u0441\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043e\u0431\u0449\u0438\u0439 \u0442\u0440\u0430\u0444\u0438\u043a             unique_dict[source] = 0             for sr, tg, vl in zip_lists:                 if sr == source:                     unique_dict[source] += vl                          # \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u044b     for source, target, value in zip_lists:         new_list.append(round(100 * value \/ unique_dict[source], 1))          return new_list<\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def lists_for_plot(source_indexes=source_indexes, colors=colors_dict, frac=10):          \"\"\"     \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c     \u0438\u0445 \u0432 \u0432\u0438\u0434\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f          Args:         source_indexes (dict): \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 source.         colors (dict): \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0446\u0432\u0435\u0442\u0430\u043c\u0438 source.         frac (int): \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \"\u043e\u0431\u044a\u0435\u043c\" \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438.              Returns:         dict: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0434\u043b\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b.     \"\"\"          sources = []     targets = []     values = []     labels = []     link_color = []     link_text = []      # \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0448\u0430\u0433\u0443     for step in tqdm(sorted(df_comp['step'].unique()), desc='\u0428\u0430\u0433'):         if step + 1 not in source_indexes:             continue          # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430         temp_dict_source = source_indexes[step]['sources_dict']          # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0446\u0435\u043b\u0438         temp_dict_target = source_indexes[step+1]['sources_dict']          # \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0439 \u043f\u0430\u0440\u0435, \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0430\u043a\u0438\u0445 \u043f\u0430\u0440         for source, index_source in tqdm(temp_dict_source.items()):             for target, index_target in temp_dict_target.items():                 # \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0440\u0435\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e id                             temp_df = df_comp[(df_comp['step'] == step)&amp;(df_comp['source'] == source)&amp;(df_comp['target'] == target)]                 value = len(temp_df)                 # \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435                 if value &gt; frac:                     sources.append(index_source)                     targets.append(index_target)                     values.append(value)                     # \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u0442\u043e\u043a \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f                     link_color.append(colors[source].replace(', 1)', ', 0.2)'))                          labels = []     colors_labels = []     for key in source_indexes:         for name in source_indexes[key]['sources']:             labels.append(name)             colors_labels.append(colors[name])                  # \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u044b \u0432\u0441\u0435\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432     perc_values = percent_users(sources, targets, values)          # \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f howertext     link_text = []     for perc in perc_values:         link_text.append(f\"{perc}%\")          # \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0438\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438     return {'sources': sources,              'targets': targets,              'values': values,              'labels': labels,              'colors_labels': colors_labels,              'link_color': link_color,              'link_text': link_text}     # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c data_for_plot = lists_for_plot()<\/code><\/pre>\n<p>\u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u043f\u0438\u0441\u043a\u0438 &#8212; \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u0446\u0432\u0435\u0442\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u0432 sources, targets, values.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 frac \u0444\u0443\u043d\u043a\u0446\u0438\u0438 lists_for_plot. \u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0443\u0437\u043b\u043e\u0432 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0438 \u043e\u0431\u044a\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0430\u043b. \u042d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e &#8212; \u0448\u0430\u0433 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 10 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 id \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438). \u0412\u0441\u0451 \u0447\u0442\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0441\u0435\u0447\u0435\u043d\u043e \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b. \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0435\u0433\u043e \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e senkey_diagram \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438:<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def plot_senkey_diagram(data_dict=data_for_plot):              \"\"\"     \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0421\u0435\u043d\u043a\u0435\u0439           Args:         data_dict (dict): \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f.              Returns:         plotly.graph_objs._figure.Figure: \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.     \"\"\"          fig = go.Figure(data=[go.Sankey(         domain = dict(           x =  [0,1],           y =  [0,1]         ),         orientation = \"h\",         valueformat = \".0f\",         node = dict(           pad = 50,           thickness = 15,           line = dict(color = \"black\", width = 0.1),           label = data_dict['labels'],           color = data_dict['colors_labels']         ),         link = dict(           source = data_dict['sources'],           target = data_dict['targets'],           value = data_dict['values'],           label = data_dict['link_text'],           color = data_dict['link_color']       ))])     fig.update_layout(title_text=\"Sankey Diagram\", font_size=10, width=3000, height=1200)          # \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b     return fig     # \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e senkey_diagram = plot_senkey_diagram()<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0427\u0442\u043e\u0431\u044b \u0435\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c:<\/p>\n<pre><code class=\"python\">senkey_diagram.show()<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b3c\/b2f\/0d0\/b3cb2f0d0b0b96666cb2456bab2d73d4.gif\" width=\"888\" height=\"530\"><figcaption><\/figcaption><\/figure>\n<h2>\u0427\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c?<\/h2>\n<h2>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 html<\/h2>\n<p>\u0414\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0448\u0430\u0433\u043e\u0432, \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0435 \u0432 html, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u0422\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0441\u043a\u0440\u043e\u043b\u043b\u0438\u0442\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0432 html<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">senkey_diagram.write_html('demo_senkey.html', auto_open=True)<\/code><\/pre>\n<p>\u0417\u0430\u0434\u0430\u0439\u0442\u0435 \u043b\u044e\u0431\u043e\u0435 \u0438\u043c\u044f html \u0444\u0430\u0439\u043b\u0443. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 auto_open \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<\/div>\n<\/details>\n<h3>\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432 Plotly Chart Studio<\/h3>\n<p>\u041c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443 \u0432 Plotly Chart Studio \u0434\u043b\u044f \u043e\u043d\u043b\u0430\u0439\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441 \u043b\u044e\u0431\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/chart-studio.plotly.com\/feed\/#\/\" rel=\"noopener noreferrer nofollow\">\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0430\u043a\u043a\u0430\u0443\u043d\u0442<\/a>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 (\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u044b <a href=\"https:\/\/plotly.com\/python\/getting-started-with-chart-studio\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>):<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 chart_studio<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import chart_studio chart_studio.tools.set_credentials_file(username='YOU_LOGIN', api_key='YOU_API_KEY')<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0432\u0430\u0448\u0443 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443:<\/p>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0432 chart_studio<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">py.plot(senkey_diagram, filename = 'NAME_FIG', auto_open=True)<\/code><\/pre>\n<\/div>\n<\/details>\n<p><a href=\"https:\/\/chart-studio.plotly.com\/~serega_408\/1.embed\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430<\/a>, \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u0430\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u043a\u0430\u043a \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443 \u0421\u044d\u043d\u043a\u0435\u0439 &#8212; \u043e\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0433\u0430\u0439\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0438 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Plotly. <br \/>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/566568\/\"> https:\/\/habr.com\/ru\/post\/566568\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Aliradar. \u041c\u044b \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u0425\u0430\u0431\u0440\u0435, \u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u0434\u043d\u0430\u043a\u043e\u043f\u0438\u043b\u0441\u044f \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f. \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u043c\u0435\u043d\u044f \u0441\u043f\u043e\u0434\u0432\u0438\u0433\u043b\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0433\u043e\u0434\u043d\u044b\u0445 \u0433\u0430\u0439\u0434\u043e\u0432 \u043f\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0421\u044d\u043d\u043a\u0435\u0439 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c python \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435.<\/p>\n<p>\u0412 \u043c\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u043a\u043e\u043d\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0435\u0448\u0430\u043b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u043e &#8212; \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0443 \u043d\u0430\u0441 \u043c\u043d\u043e\u0433\u043e, \u0442\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e &#8212; \u0442\u0440\u0443\u0434\u043d\u0430\u044f \u0438 \u0434\u043e\u0440\u043e\u0433\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443 \u0421\u044d\u043d\u043a\u0435\u0439 (Sankey diagram).<\/p>\n<p>\u0417\u0430\u0431\u0435\u0433\u0430\u044f \u0432\u043f\u0435\u0440\u0435\u0434, \u043f\u043e\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f <a href=\"https:\/\/chart-studio.plotly.com\/~serega_408\/1.embed\" rel=\"noopener noreferrer nofollow\">\u0432 \u0438\u0442\u043e\u0433\u0435<\/a>. \u0414\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b python, pandas \u0438 plotly. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 <a href=\"https:\/\/colab.research.google.com\/github\/rusantsovsv\/senkey_tutorial\/blob\/main\/senkey_colab.ipynb\" rel=\"noopener noreferrer nofollow\">colab<\/a>, \u043b\u0438\u0431\u043e \u0432\u0437\u044f\u0442\u044c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 <a href=\"https:\/\/github.com\/rusantsovsv\/senkey_tutorial\" rel=\"noopener noreferrer nofollow\">github<\/a>.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e.<\/p>\n<h2>\u0427\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435?<\/h2>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u044d\u0442\u043e\u0439 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b <a href=\"https:\/\/en.wikipedia.org\/wiki\/Sankey_diagram\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432 1898 \u0433\u043e\u0434\u0443<\/a>. \u0415\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c, \u041c\u044d\u0442\u044c\u044e \u0421\u0435\u043d\u043a\u0435\u0439 (Matthew H. Sankey), \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f \u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f \u0431\u0435\u0437 \u044d\u043d\u0435\u0440\u0433\u043e\u043f\u043e\u0442\u0435\u0440\u044c.<\/p>\n<figure class=\"full-width\"><figcaption>\u0422\u0435\u043f\u043b\u043e\u0432\u0430\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0430\u0440\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f<\/figcaption><\/figure>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u0421\u044d\u043d\u043a\u0435\u0439 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 &#8212; \u044d\u0442\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u0412\u043e\u0442 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430, \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f:<\/p>\n<figure class=\"full-width\"><figcaption>\u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0421\u044d\u043d\u043a\u0435\u0439<\/figcaption><\/figure>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u044d\u0442\u0443 \u0441\u0445\u0435\u043c\u0443:<\/p>\n<ul>\n<li>\n<p>\u0435\u0441\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 event_1, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u043d\u044c\u0448\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0435\u0432\u0435\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0430 \u0441\u0445\u0435\u043c\u0435. \u0422\u0430\u043a\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c (source);<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 &#171;\u043f\u0435\u0440\u0435\u0445\u043e\u0434&#187; \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u0442 event_1 (source) \u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c event_1, event_2, event_3, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0448\u0430\u0433\u0435 (step_1) \u0446\u0435\u043b\u0435\u0432\u044b\u043c\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438 (target). \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0432\u0448\u0438\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442 source \u043a target \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0438\u0440\u0438\u043d\u044b \u043a\u0430\u043d\u0430\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 source \u0438 target;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430 \u0448\u0430\u0433\u0435 step_2 \u0443\u0436\u0435 event_1, event_2, event_3 \u0431\u0443\u0434\u0443\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438, \u0430 event_3 \u0438 event_4 \u0446\u0435\u043b\u0435\u0432\u044b\u043c\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442 \u0448\u0430\u0433\u0430 \u043a \u0448\u0430\u0433\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f source \u043d\u0430 target. \u0421\u0430\u043c\u043e\u0435 \u043f\u0435\u0440\u0432\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 &#8212; \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e source, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 &#8212; \u044d\u0442\u043e target, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 source \u043d\u0435\u0442 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0430 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0442\u0430\u0440\u0433\u0435\u0442\u0430 \u043d\u0435\u0442 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u0430 \u0441\u0445\u0435\u043c\u0430 &#8212; \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 \u043d\u0435\u0439 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 source, \u0438 \u043e\u0434\u0438\u043d \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 target. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438 source \u0438 target \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435, \u043a\u0430\u043a \u0438 \u0441\u0430\u043c\u0438\u0445 \u0448\u0430\u0433\u043e\u0432, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e.<\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. <\/p>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">PATH_TO_CSV = 'https:\/\/raw.githubusercontent.com\/rusantsovsv\/senkey_tutorial\/main\/csv\/senkey_data_tutorial.csv'  # \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a table = pd.read_csv(PATH_TO_CSV) table.head()<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<ul>\n<li>\n<p>user_id &#8212; \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f;<\/p>\n<\/li>\n<li>\n<p>event_timestamp &#8212; \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>event_name &#8212; \u0438\u043c\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0430\u0440\u044b source-target, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u0430\u0440\u044b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f &#8212; \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0448\u0430\u0433 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def add_features(df):          \"\"\"\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0434\u043b\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b      Args:         df (pd.DataFrame): \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430.     Returns:         pd.DataFrame: \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438.     \"\"\"          # \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e id \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438     sorted_df = df.sort_values(by=['user_id', 'event_timestamp']).copy()     # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0448\u0430\u0433\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439     sorted_df['step'] = sorted_df.groupby('user_id').cumcount() + 1          # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u0437\u043b\u044b-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0438 \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0443\u0437\u043b\u044b     # \u0443\u0437\u043b\u044b-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 - \u044d\u0442\u043e \u0441\u0430\u043c\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f     sorted_df['source'] = sorted_df['event_name']     # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0443\u0437\u043b\u044b     sorted_df['target'] = sorted_df.groupby('user_id')['source'].shift(-1)          # \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0435\u0437 \u0438\u043c\u0435\u043d\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439     return sorted_df.drop(['event_name'], axis=1)    # \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 table = add_features(table) table.head()<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e id \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043f\u0430\u0440\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u0439 source &#8212; target;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0448\u0430\u0433 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0434\u0430\u043b\u0435\u043d \u0441\u0442\u043e\u043b\u0431\u0435\u0446 event_name, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0448\u0430\u0433\u043e\u0432 \u043d\u0430 \u043d\u0430\u0448\u0435\u0439 \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0435. \u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0448\u0430\u0433\u043e\u0432, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043e, \u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0448\u0430\u0433\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0432\u043d\u044b\u043c 7.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0448\u0430\u0433\u043e\u0432 \u0434\u043e 7<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\"># \u0443\u0434\u0430\u043b\u0438\u043c \u0432\u0441\u0435 \u043f\u0430\u0440\u044b source-target, \u0448\u0430\u0433 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 7 # \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e df_comp = table[table['step'] &lt;= 7].copy().reset_index(drop=True)<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f source<\/h2>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0432 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f source. \u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435 target \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f source, \u0438 \u0447\u0442\u043e\u0431\u044b \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u043a\u043e\u0440\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0443\u0436\u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f source \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u043b\u044e\u0447\u0438 &#8212; \u044d\u0442\u043e \u0448\u0430\u0433\u0438, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f &#8212; \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 source \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.&nbsp;\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b source \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044e, \u0430 \u043d\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0441 0, \u043f\u0440\u0438 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0448\u0430\u0433\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0438\u043c\u0435\u043d\u0430 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c. \u0412\u0441\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u043a, \u043f\u043e\u0434\u043f\u0438\u0441\u0435\u0439 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 source \u0438 target.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 source<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def get_source_index(df):          \"\"\"\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 source      Args:         df (pd.DataFrame): \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 step, source, target.     Returns:         dict: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438, \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0438\u044f\u043c\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438\u043c\u0435\u043d\u0430\u043c source.     \"\"\"          res_dict = {}          count = 0     # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432     for no, step in enumerate(df['step'].unique().tolist()):         # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0448\u0430\u0433\u0430         res_dict[no+1] = {}         res_dict[no+1]['sources'] = df[df['step'] == step]['source'].unique().tolist()         res_dict[no+1]['sources_index'] = []         for i in range(len(res_dict[no+1]['sources'])):             res_dict[no+1]['sources_index'].append(count)             count += 1                  # \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043c \u0441\u043f\u0438\u0441\u043a\u0438     for key in res_dict:         res_dict[key]['sources_dict'] = {}         for name, no in zip(res_dict[key]['sources'], res_dict[key]['sources_index']):             res_dict[key]['sources_dict'][name] = no     return res_dict     # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c source_indexes = get_source_index(df_comp)<\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u0434\u043b\u044f \u0448\u0430\u0433\u0430 2<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">sources  ['history_opened', 'app_opened_from_market', 'sales_category_selected', 'favorites_opened', 'item_opened', 'app_opened_via_icon', 'market_opened_without_referral', 'price_history_opened', 'search_tab_opened', 'seller_info_opened', 'item_loaded_from_store', 'marketApp_opened', 'chart_click', 'item_opened_from_history', 'similar_tab_opened', 'reviews_tab_opened', 'app_remove', 'similar_item_opened', 'marketApp_opened_from_item', 'sales_item_opened_from_main', 'auth_opened', 'search_request_entered', 'item_info_click', 'sales_opened', 'settings_opened', 'similars_not_fetched_from_server', 'auth_user_succeeded', 'search_results_loaded']   sources_index  [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]   sources_dict  {'history_opened': 20, 'app_opened_from_market': 21, 'sales_category_selected': 22, 'favorites_opened': 23, 'item_opened': 24, 'app_opened_via_icon': 25, 'market_opened_without_referral': 26, 'price_history_opened': 27, 'search_tab_opened': 28, 'seller_info_opened': 29, 'item_loaded_from_store': 30, 'marketApp_opened': 31, 'chart_click': 32, 'item_opened_from_history': 33, 'similar_tab_opened': 34, 'reviews_tab_opened': 35, 'app_remove': 36, 'similar_item_opened': 37, 'marketApp_opened_from_item': 38, 'sales_item_opened_from_main': 39, 'auth_opened': 40, 'search_request_entered': 41, 'item_info_click': 42, 'sales_opened': 43, 'settings_opened': 44, 'similars_not_fetched_from_server': 45, 'auth_user_succeeded': 46, 'search_results_loaded': 47}<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432 \u0434\u043b\u044f source<\/h2>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0443\u043a\u0440\u0430\u0441\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 source-target \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430. \u042f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b 2 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 &#8212; \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438 \u0440\u0443\u0447\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u0446\u0432\u0435\u0442\u043e\u0432. <\/p>\n<p>\u0426\u0432\u0435\u0442\u0430 \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0432 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 RGBA. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043d\u0430\u043b\u044b source-target \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c\u0438, \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a \u0431\u043b\u043e\u043a\u0430\u043c \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u0441\u0445\u0435\u043c\u044b.<\/p>\n<p>\u0426\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f source:color. \u041f\u043e \u043b\u0438\u0447\u043d\u043e\u043c\u0443 \u0441\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u0431\u0440\u0430\u043b \u0442\u0435 \u0446\u0432\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043d\u0430 \u0431\u0435\u043b\u043e\u043c \u0444\u043e\u043d\u0435. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c, \u0443\u043a\u0430\u0437\u0430\u0432 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 colors_for_sources \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 mode=&#8217;custom&#8217; (&#8216;random&#8217; \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0432\u0435\u0442\u0430).<\/p>\n<details class=\"spoiler\">\n<summary>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0432\u0435\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def generate_random_color():          \"\"\"\u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432 rgba      Args:              Returns:         str: \u0421\u0442\u0440\u043e\u043a\u0430 \u0441\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0446\u0432\u0435\u0442\u0430     \"\"\"          # \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430     r, g, b = np.random.randint(255, size=3)     return f'rgba({r}, {g}, {b}, 1)'<\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f\u043c\u0438 source: color<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def colors_for_sources(mode):          \"\"\"\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432 rgba      Args:         mode (str): \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430, \u0435\u0441\u043b\u0438 'random', \u0430 \u0435\u0441\u043b\u0438 'custom' -                      \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435     Returns:         dict: \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0446\u0432\u0435\u0442\u0430\u043c\u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043a\u0430\u0436\u0434\u043e\u043c\u0443<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-326096","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326096","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326096"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326096\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}