{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "machine_shape": "hm",
      "gpuType": "T4"
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU",
    "widgets": {
      "application/vnd.jupyter.widget-state+json": {
        "a336f820e5124f5d9e344bb8b0d12ee5": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_150475d8c96148eaa9d5230b85283e64",
              "IPY_MODEL_19f3e10b3dd94c71b9add7ee1d8f4c13",
              "IPY_MODEL_5aa33fe21abc482c997975ec5712d0da"
            ],
            "layout": "IPY_MODEL_0b51be1ad43c43fa89041fea2b062768"
          }
        },
        "150475d8c96148eaa9d5230b85283e64": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_5ab992330571497ab2a07cd04841b9d3",
            "placeholder": "​",
            "style": "IPY_MODEL_4a8897c90c19427fa82afa4fa62f31da",
            "value": "Optimization Progress: 100%"
          }
        },
        "19f3e10b3dd94c71b9add7ee1d8f4c13": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_7df01173ffee4067b1c7490fab0b571b",
            "max": 120,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_6bd42f421a4e4e60b2d7edc8784e07aa",
            "value": 120
          }
        },
        "5aa33fe21abc482c997975ec5712d0da": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_09932ad0a1fe4fd196b38b16dc74f94a",
            "placeholder": "​",
            "style": "IPY_MODEL_f7354d5ee6e04705968e30d7a43ebbe7",
            "value": " 120/120 [01:53&lt;00:00,  1.21pipeline/s]"
          }
        },
        "0b51be1ad43c43fa89041fea2b062768": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "5ab992330571497ab2a07cd04841b9d3": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "4a8897c90c19427fa82afa4fa62f31da": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "7df01173ffee4067b1c7490fab0b571b": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "6bd42f421a4e4e60b2d7edc8784e07aa": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "09932ad0a1fe4fd196b38b16dc74f94a": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "f7354d5ee6e04705968e30d7a43ebbe7": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "feb69d6d248b4e2abf52d6622dd3638b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_712ff38a74994c5082fe487de437ec67",
              "IPY_MODEL_81a29faa64d44f2c9a173a9213618f4c",
              "IPY_MODEL_35012b6363cf4ca88c4c5221d264ec25"
            ],
            "layout": "IPY_MODEL_598537621c514f51be27ebaf9bde7d54"
          }
        },
        "712ff38a74994c5082fe487de437ec67": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_825b3f67b44b4136a36909da95412031",
            "placeholder": "​",
            "style": "IPY_MODEL_8b121673d208412ab1f426a3ff1698ba",
            "value": "Optimization Progress: 100%"
          }
        },
        "81a29faa64d44f2c9a173a9213618f4c": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_02a6753498b14c459016b7ff31c4b6d7",
            "max": 120,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_384c150f10e94ba78243d1a260e66887",
            "value": 120
          }
        },
        "35012b6363cf4ca88c4c5221d264ec25": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_bb1d1e093dec47f393c713548bfc6cc6",
            "placeholder": "​",
            "style": "IPY_MODEL_05b2a6fb28aa434a94c18c7d64cd55f1",
            "value": " 120/120 [06:21&lt;00:00,  1.55s/pipeline]"
          }
        },
        "598537621c514f51be27ebaf9bde7d54": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "825b3f67b44b4136a36909da95412031": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "8b121673d208412ab1f426a3ff1698ba": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "02a6753498b14c459016b7ff31c4b6d7": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "384c150f10e94ba78243d1a260e66887": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "bb1d1e093dec47f393c713548bfc6cc6": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "05b2a6fb28aa434a94c18c7d64cd55f1": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "a2f43127d721436185ba241b84cc87d7": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_3618c2d6264c4359a17bbdecc7db70d8",
              "IPY_MODEL_286cc95f7d6c47a6863c7fda02f83d3f",
              "IPY_MODEL_cabaca33a5cc4d0fb9fa99f42ece4167"
            ],
            "layout": "IPY_MODEL_153d243e01b24b5cad305ec4d886b922"
          }
        },
        "3618c2d6264c4359a17bbdecc7db70d8": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_e8bf60db6d1b47b2a6752fcceebad0e7",
            "placeholder": "​",
            "style": "IPY_MODEL_600f0f18ccaf4c89aa37feaa0b360f13",
            "value": "Optimization Progress: 100%"
          }
        },
        "286cc95f7d6c47a6863c7fda02f83d3f": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_33f5284de07e4be29e4f39d5aaaa2d9b",
            "max": 120,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_4a850f0d51014dfa9b55c86d04707b24",
            "value": 120
          }
        },
        "cabaca33a5cc4d0fb9fa99f42ece4167": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_ae8a589b32c44836894c6d3b708b896d",
            "placeholder": "​",
            "style": "IPY_MODEL_a57766432bb54d24a3869e0553c026d1",
            "value": " 120/120 [05:13&lt;00:00,  1.83s/pipeline]"
          }
        },
        "153d243e01b24b5cad305ec4d886b922": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "e8bf60db6d1b47b2a6752fcceebad0e7": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "600f0f18ccaf4c89aa37feaa0b360f13": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "33f5284de07e4be29e4f39d5aaaa2d9b": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "4a850f0d51014dfa9b55c86d04707b24": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "ae8a589b32c44836894c6d3b708b896d": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "a57766432bb54d24a3869e0553c026d1": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "2cf8dcb41b3340cea65c251b3d8681d4": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_6e3a5bb9d6d7456982660f0edcc3b8c0",
              "IPY_MODEL_0bb2408ba21a481983c0a74f1411ef0a",
              "IPY_MODEL_4528e59b16d04228a5cc508fadb56a54"
            ],
            "layout": "IPY_MODEL_61072176986f4c9fb48f403c25ac3024"
          }
        },
        "6e3a5bb9d6d7456982660f0edcc3b8c0": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_9881b9f569b3445897972c0340870318",
            "placeholder": "​",
            "style": "IPY_MODEL_f09971fa706c4509b3530edabeb47864",
            "value": "Optimization Progress: 100%"
          }
        },
        "0bb2408ba21a481983c0a74f1411ef0a": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_7510b9c108494e3dbe5ee031bf367e2b",
            "max": 120,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_2ed7ace57f89415fba714200fe44c2f9",
            "value": 120
          }
        },
        "4528e59b16d04228a5cc508fadb56a54": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_bb51c5c7834c419a87a30752cd769d91",
            "placeholder": "​",
            "style": "IPY_MODEL_cc9bf86d64fc48f490a38fae5483ddb2",
            "value": " 120/120 [07:12&lt;00:00,  2.45s/pipeline]"
          }
        },
        "61072176986f4c9fb48f403c25ac3024": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "9881b9f569b3445897972c0340870318": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "f09971fa706c4509b3530edabeb47864": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "7510b9c108494e3dbe5ee031bf367e2b": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "2ed7ace57f89415fba714200fe44c2f9": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "bb51c5c7834c419a87a30752cd769d91": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "cc9bf86d64fc48f490a38fae5483ddb2": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "ed38c4b5280a4e0da6b3e979ca380db5": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_045cf04f33a643e8816a674d659cc252",
              "IPY_MODEL_c5b0b6bebd0b49e0b10116770251023e",
              "IPY_MODEL_c42b63c849f7469496fa292cc53efae3"
            ],
            "layout": "IPY_MODEL_a336fafd8e334185a39ca81268ca9f90"
          }
        },
        "045cf04f33a643e8816a674d659cc252": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_007b3fd39d1c480c959db4ed7abb37fe",
            "placeholder": "​",
            "style": "IPY_MODEL_5247fe5ea6724b15934a7142b8a8a8b1",
            "value": "Optimization Progress: 100%"
          }
        },
        "c5b0b6bebd0b49e0b10116770251023e": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_ff008c746112461781825f85f212dd81",
            "max": 120,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_c290371939ed4a8999c1411b426448ed",
            "value": 120
          }
        },
        "c42b63c849f7469496fa292cc53efae3": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_09e3fa8828024d1cab95af2452cbf516",
            "placeholder": "​",
            "style": "IPY_MODEL_b1f5ea5f99b249dc9c8d2b26f43485f0",
            "value": " 120/120 [04:12&lt;00:00,  1.85s/pipeline]"
          }
        },
        "a336fafd8e334185a39ca81268ca9f90": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "007b3fd39d1c480c959db4ed7abb37fe": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "5247fe5ea6724b15934a7142b8a8a8b1": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "ff008c746112461781825f85f212dd81": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "c290371939ed4a8999c1411b426448ed": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "09e3fa8828024d1cab95af2452cbf516": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "b1f5ea5f99b249dc9c8d2b26f43485f0": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "b41836beb11a4623b7fa6091494c0e85": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_d1fb8e94033f47d3b7123c513473519d",
              "IPY_MODEL_0f90f79a7f0d4bcbaa2ada2379b65f53",
              "IPY_MODEL_dedf553fc5c24b14a86a779a61a39be5"
            ],
            "layout": "IPY_MODEL_6566843282bc4bb59c7044ab3b812f40"
          }
        },
        "d1fb8e94033f47d3b7123c513473519d": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_fcefb4debd9a4445a94a9fc5847662e4",
            "placeholder": "​",
            "style": "IPY_MODEL_bbe6750092e44b2aafc5afb33e71ae88",
            "value": "Optimization Progress: 100%"
          }
        },
        "0f90f79a7f0d4bcbaa2ada2379b65f53": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_50769ac7392e4bccaf83e32f8e5e3754",
            "max": 120,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_f202232d07f946ccaf899e672c2b7dd7",
            "value": 120
          }
        },
        "dedf553fc5c24b14a86a779a61a39be5": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_111571775b67440db61746dc6a653380",
            "placeholder": "​",
            "style": "IPY_MODEL_1fc51b4708134f18995b5dd73631446d",
            "value": " 120/120 [05:59&lt;00:00,  2.15s/pipeline]"
          }
        },
        "6566843282bc4bb59c7044ab3b812f40": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "fcefb4debd9a4445a94a9fc5847662e4": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "bbe6750092e44b2aafc5afb33e71ae88": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "50769ac7392e4bccaf83e32f8e5e3754": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "f202232d07f946ccaf899e672c2b7dd7": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "111571775b67440db61746dc6a653380": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "1fc51b4708134f18995b5dd73631446d": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "f466f42deeac4321b8b9768a11d6a755": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_06b74e83419b4d2b94913aeb490a7cb0",
              "IPY_MODEL_de16524e0e5d46f9a8b511fa82e748a8",
              "IPY_MODEL_e13204ee59ab400280347f23c0d31705"
            ],
            "layout": "IPY_MODEL_ad599c9ce9b04059b37c94dcae4b23a8"
          }
        },
        "06b74e83419b4d2b94913aeb490a7cb0": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_aeefdbc3453543baa3d6e72ccd15ee54",
            "placeholder": "​",
            "style": "IPY_MODEL_3a84a44443a944c399486902d4db6bdc",
            "value": "Optimization Progress: 100%"
          }
        },
        "de16524e0e5d46f9a8b511fa82e748a8": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_2e55913ae8944ef9923724a8351bacb4",
            "max": 120,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_dcc3e817b40643388a5f99a54fe13e43",
            "value": 120
          }
        },
        "e13204ee59ab400280347f23c0d31705": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_272dc71a7ccf4608bfdea6a17524a886",
            "placeholder": "​",
            "style": "IPY_MODEL_5a3d943f85e34887aeb64a0e6b189f32",
            "value": " 120/120 [09:53&lt;00:00,  1.47s/pipeline]"
          }
        },
        "ad599c9ce9b04059b37c94dcae4b23a8": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "aeefdbc3453543baa3d6e72ccd15ee54": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "3a84a44443a944c399486902d4db6bdc": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "2e55913ae8944ef9923724a8351bacb4": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "dcc3e817b40643388a5f99a54fe13e43": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "272dc71a7ccf4608bfdea6a17524a886": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "5a3d943f85e34887aeb64a0e6b189f32": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "065f516618c041f1ba57df39d17cc95d": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_ca2767bb06444f03a1a31dd9e5216c45",
              "IPY_MODEL_1d9710db98c04adeb3855f4062301e24",
              "IPY_MODEL_57141f99793f45708db3961cf4178fc9"
            ],
            "layout": "IPY_MODEL_6c4c02ca0cb64050ac7e201a1a60be72"
          }
        },
        "ca2767bb06444f03a1a31dd9e5216c45": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_b6b5382bb2684e74a2c36b49f423eee3",
            "placeholder": "​",
            "style": "IPY_MODEL_a4a4a02a4332458789866a0e0e7839d3",
            "value": "Optimization Progress: 100%"
          }
        },
        "1d9710db98c04adeb3855f4062301e24": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_871438bb5a0d4d31b3b8a0f18fcdac78",
            "max": 120,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_294ffc18963140ea96c01095e3a1300f",
            "value": 120
          }
        },
        "57141f99793f45708db3961cf4178fc9": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_6dda83426ca749bd822d2bd0d39744ed",
            "placeholder": "​",
            "style": "IPY_MODEL_d37293f1d67f45babbe2a875df701c40",
            "value": " 120/120 [04:43&lt;00:00,  5.74s/pipeline]"
          }
        },
        "6c4c02ca0cb64050ac7e201a1a60be72": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "b6b5382bb2684e74a2c36b49f423eee3": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "a4a4a02a4332458789866a0e0e7839d3": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "871438bb5a0d4d31b3b8a0f18fcdac78": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "294ffc18963140ea96c01095e3a1300f": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "6dda83426ca749bd822d2bd0d39744ed": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "d37293f1d67f45babbe2a875df701c40": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "2ae5d11987c44076b95c1294af800c28": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_75c27d61248b477e9c58211b066ab62f",
              "IPY_MODEL_00628b308f4244c4ad533a67cb90ba43",
              "IPY_MODEL_851e8257d678458db2612a04803e8c17"
            ],
            "layout": "IPY_MODEL_8f472688c98745f28345f31e852b361b"
          }
        },
        "75c27d61248b477e9c58211b066ab62f": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_f1b8071a183e47af81e8d96290ca7370",
            "placeholder": "​",
            "style": "IPY_MODEL_18d1acb1cdad46f1832c98ab44f0bc53",
            "value": "Optimization Progress: 100%"
          }
        },
        "00628b308f4244c4ad533a67cb90ba43": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_21abac8483874bb1acdc45f6e8f78b53",
            "max": 120,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_b4e4db272e35407899de20c7b30d1551",
            "value": 120
          }
        },
        "851e8257d678458db2612a04803e8c17": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_9d4143827e3f4e949cde68384a7beb59",
            "placeholder": "​",
            "style": "IPY_MODEL_aa805872f24140f6aa6ee2ac72b34b59",
            "value": " 120/120 [04:12&lt;00:00,  1.73pipeline/s]"
          }
        },
        "8f472688c98745f28345f31e852b361b": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "f1b8071a183e47af81e8d96290ca7370": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "18d1acb1cdad46f1832c98ab44f0bc53": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "21abac8483874bb1acdc45f6e8f78b53": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "b4e4db272e35407899de20c7b30d1551": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "9d4143827e3f4e949cde68384a7beb59": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "aa805872f24140f6aa6ee2ac72b34b59": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "ed028f92fe6544159b14dcf220623223": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_2ff14125384a4f3cad97a03f9d2ff55f",
              "IPY_MODEL_d70eced834c64f399a3db48dcc19f802",
              "IPY_MODEL_b85cfd236fbc4c50b2572f0ff7ddea1c"
            ],
            "layout": "IPY_MODEL_b4e51caccd1e40baac5143667206d8cb"
          }
        },
        "2ff14125384a4f3cad97a03f9d2ff55f": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_8031586f1f8d4dbbaf44708b12f4eb13",
            "placeholder": "​",
            "style": "IPY_MODEL_a2278a2947354727a76758cb4bf5e682",
            "value": "Optimization Progress: 100%"
          }
        },
        "d70eced834c64f399a3db48dcc19f802": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_a2debbdff91649f29c7a579911090df4",
            "max": 120,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_7d4b85786ff04c9d843753c91c80f854",
            "value": 120
          }
        },
        "b85cfd236fbc4c50b2572f0ff7ddea1c": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_cb681559245a4d12bd4551bcfea063c4",
            "placeholder": "​",
            "style": "IPY_MODEL_0967c0fe1d9a4048b4e7b4266a75d893",
            "value": " 120/120 [05:41&lt;00:00,  2.27s/pipeline]"
          }
        },
        "b4e51caccd1e40baac5143667206d8cb": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "8031586f1f8d4dbbaf44708b12f4eb13": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "a2278a2947354727a76758cb4bf5e682": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "a2debbdff91649f29c7a579911090df4": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "7d4b85786ff04c9d843753c91c80f854": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "cb681559245a4d12bd4551bcfea063c4": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "0967c0fe1d9a4048b4e7b4266a75d893": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "8a807c2780cf4a65ad92dfa1ead0e439": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_021bf8d789b74e3d899a99eeb82a0036",
              "IPY_MODEL_f7aeed7c0692419591ca57bffee51739",
              "IPY_MODEL_d7f2da7e3beb42dfaf31dc69eb7a597e"
            ],
            "layout": "IPY_MODEL_c7b913c695fc448c8fc7b31f7098f636"
          }
        },
        "021bf8d789b74e3d899a99eeb82a0036": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_a59325353a1d4902b03f5a37c0293934",
            "placeholder": "​",
            "style": "IPY_MODEL_6cd3d0fc462c4b14bbe6be92b8e6103e",
            "value": "100%"
          }
        },
        "f7aeed7c0692419591ca57bffee51739": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_0cfdc6a2fa49499e9f0ce350b88dfbc4",
            "max": 3288938,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_a9c70dae97424ca290a75e10d24baf52",
            "value": 3288938
          }
        },
        "d7f2da7e3beb42dfaf31dc69eb7a597e": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_f0fc3fee01b04ffc922096ee18b6cb0f",
            "placeholder": "​",
            "style": "IPY_MODEL_9142d6e9793648a9909e5ce3dabf415b",
            "value": " 3.29M/3.29M [00:00&lt;00:00, 9.24MiB/s]"
          }
        },
        "c7b913c695fc448c8fc7b31f7098f636": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "a59325353a1d4902b03f5a37c0293934": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "6cd3d0fc462c4b14bbe6be92b8e6103e": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "0cfdc6a2fa49499e9f0ce350b88dfbc4": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "a9c70dae97424ca290a75e10d24baf52": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "f0fc3fee01b04ffc922096ee18b6cb0f": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "9142d6e9793648a9909e5ce3dabf415b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "2380e728c4b94d4a82d99c5df53bcfb8": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_60e0fda3b0b64788b12de0492e48a8eb",
              "IPY_MODEL_b4aab6b20b704970a6d88b4203aafe33",
              "IPY_MODEL_94853d6fcd9e485ab00941270501bdc2"
            ],
            "layout": "IPY_MODEL_85171f4f5f6f4cf798c8f0afc85c0f45"
          }
        },
        "60e0fda3b0b64788b12de0492e48a8eb": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_188af8de0a894c4b862c04ae22f6e2ab",
            "placeholder": "​",
            "style": "IPY_MODEL_cca3270cffa747b0819b1a50fff1ef02",
            "value": "Optimization Progress: 100%"
          }
        },
        "b4aab6b20b704970a6d88b4203aafe33": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_2f02cde9cf5f45fc8ce05a545baad40c",
            "max": 20,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_aa35eac1e7964054bf8ab8903cd3e182",
            "value": 20
          }
        },
        "94853d6fcd9e485ab00941270501bdc2": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_bf41ac8c2a6f47e6b6956e4389485e3e",
            "placeholder": "​",
            "style": "IPY_MODEL_6f7d22c33bbd434e83d5764c7ebed942",
            "value": " 120/120 [01:48&lt;00:00,  1.01s/pipeline]"
          }
        },
        "85171f4f5f6f4cf798c8f0afc85c0f45": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "188af8de0a894c4b862c04ae22f6e2ab": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "cca3270cffa747b0819b1a50fff1ef02": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "2f02cde9cf5f45fc8ce05a545baad40c": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "aa35eac1e7964054bf8ab8903cd3e182": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "bf41ac8c2a6f47e6b6956e4389485e3e": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "6f7d22c33bbd434e83d5764c7ebed942": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "612cffdae98544d480553f9a40e6bd01": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_9eb0c8bff0b6480caac00ebc3381b0d7",
              "IPY_MODEL_ef6da18b47a04feeabf4d5e1d0437f0b",
              "IPY_MODEL_a992cbe30d1c47b09724593a260a690c"
            ],
            "layout": "IPY_MODEL_ee97630f2ff341bfb51cedf7c99bf39c"
          }
        },
        "9eb0c8bff0b6480caac00ebc3381b0d7": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_c89e1c3487e040caa253aad97f240fe7",
            "placeholder": "​",
            "style": "IPY_MODEL_31666166fb934ef4b8d568f609db9fb3",
            "value": "Optimization Progress: 100%"
          }
        },
        "ef6da18b47a04feeabf4d5e1d0437f0b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_2ee32d42a6124f9fa35a04115268427d",
            "max": 20,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_d78b5fb09a4d4aacb52940e2a12de183",
            "value": 20
          }
        },
        "a992cbe30d1c47b09724593a260a690c": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_d8a982183d3f45d2b77dddd74f4ff9e7",
            "placeholder": "​",
            "style": "IPY_MODEL_f679dcba359e460ebe3d763e086922c7",
            "value": " 120/120 [01:46&lt;00:00,  1.14pipeline/s]"
          }
        },
        "ee97630f2ff341bfb51cedf7c99bf39c": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "c89e1c3487e040caa253aad97f240fe7": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "31666166fb934ef4b8d568f609db9fb3": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "2ee32d42a6124f9fa35a04115268427d": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "d78b5fb09a4d4aacb52940e2a12de183": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "d8a982183d3f45d2b77dddd74f4ff9e7": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "f679dcba359e460ebe3d763e086922c7": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "e329ae9f00ae426caba593bf82062720": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_6b18e9941ad8489a856d8951086dc0ec",
              "IPY_MODEL_bd1ef0b1216f44e981e06617353af203",
              "IPY_MODEL_cb16a7ccc2d048699ec81bd9cc08782b"
            ],
            "layout": "IPY_MODEL_2057161353254330b31e15c030f5c77e"
          }
        },
        "6b18e9941ad8489a856d8951086dc0ec": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_2768fc55816a4ddabd3389b3e6c9a0df",
            "placeholder": "​",
            "style": "IPY_MODEL_12c31e7d69934b1bb13b7e4de18f9aee",
            "value": "Optimization Progress: 100%"
          }
        },
        "bd1ef0b1216f44e981e06617353af203": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_d3f693b6862747fbab9f786e7ef0a9cf",
            "max": 40,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_f3a099a3356044e7a641d590c6381041",
            "value": 40
          }
        },
        "cb16a7ccc2d048699ec81bd9cc08782b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_aab64f46dfdf4948bec48ef02618cf75",
            "placeholder": "​",
            "style": "IPY_MODEL_b83434e8778040d4975f5fab89a976ec",
            "value": " 40/40 [00:09&lt;00:00,  5.26pipeline/s]"
          }
        },
        "2057161353254330b31e15c030f5c77e": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "2768fc55816a4ddabd3389b3e6c9a0df": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "12c31e7d69934b1bb13b7e4de18f9aee": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "d3f693b6862747fbab9f786e7ef0a9cf": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "f3a099a3356044e7a641d590c6381041": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "aab64f46dfdf4948bec48ef02618cf75": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "b83434e8778040d4975f5fab89a976ec": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "3ae62907413b4d969f53c4a3092fb46d": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_5af08e85e25040b19544493df13617d5",
              "IPY_MODEL_439b9e942cec4fe699f3e561082585b5",
              "IPY_MODEL_b4b43f188f454890a04bc1869680c46d"
            ],
            "layout": "IPY_MODEL_4de8382a838648b6bf2d639b5ae65c7b"
          }
        },
        "5af08e85e25040b19544493df13617d5": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_32aa5ea1c8354c0eb3538819a48e81ea",
            "placeholder": "​",
            "style": "IPY_MODEL_ed0c20dcb4764e629766a2e31d019edf",
            "value": "Optimization Progress: 100%"
          }
        },
        "439b9e942cec4fe699f3e561082585b5": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_90db1881f3254f71adf5d809c0d83bae",
            "max": 40,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_87b95caad65649a9b85bdc015c665838",
            "value": 40
          }
        },
        "b4b43f188f454890a04bc1869680c46d": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_8151a7980fc346debb0caf1c20af5429",
            "placeholder": "​",
            "style": "IPY_MODEL_2f6c4ac937de426ab94fdde3fc4fc95a",
            "value": " 40/40 [00:04&lt;00:00,  7.79pipeline/s]"
          }
        },
        "4de8382a838648b6bf2d639b5ae65c7b": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "32aa5ea1c8354c0eb3538819a48e81ea": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "ed0c20dcb4764e629766a2e31d019edf": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "90db1881f3254f71adf5d809c0d83bae": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "87b95caad65649a9b85bdc015c665838": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "8151a7980fc346debb0caf1c20af5429": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "2f6c4ac937de426ab94fdde3fc4fc95a": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "d35be0ff26cc4d0e85b498638ec728da": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_6c3982ed895846f2a07befc28277debd",
              "IPY_MODEL_a031633d17474670a3055d94249d58ee",
              "IPY_MODEL_08d30171bbb44668aea730cc7e2e828a"
            ],
            "layout": "IPY_MODEL_bda89cfac064435b8de02f41e689e0a3"
          }
        },
        "6c3982ed895846f2a07befc28277debd": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_603fa104247d4ae8888440acca48221e",
            "placeholder": "​",
            "style": "IPY_MODEL_bf6290dc87bd447da28102899e57ffe5",
            "value": "100%"
          }
        },
        "a031633d17474670a3055d94249d58ee": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_fe8beb6587574f93a2947c2bcc907091",
            "max": 8039037,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_3b5d864ced1149c4979b491cbc3070f7",
            "value": 8039037
          }
        },
        "08d30171bbb44668aea730cc7e2e828a": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_e2306dc620194ce485bd2663c7d25738",
            "placeholder": "​",
            "style": "IPY_MODEL_329389fea5f74dca965f296707c2a8d0",
            "value": " 8.04M/8.04M [00:00&lt;00:00, 29.6MiB/s]"
          }
        },
        "bda89cfac064435b8de02f41e689e0a3": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "603fa104247d4ae8888440acca48221e": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "bf6290dc87bd447da28102899e57ffe5": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "fe8beb6587574f93a2947c2bcc907091": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "3b5d864ced1149c4979b491cbc3070f7": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "e2306dc620194ce485bd2663c7d25738": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "329389fea5f74dca965f296707c2a8d0": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "9d26aed57a8244ada934039dd928555c": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_b04abee189594c62b235e5076deafc84",
              "IPY_MODEL_ff0cc2d2cf8f4009bd200fd17d7ba517",
              "IPY_MODEL_49f821f89aa44034af5988b888734185"
            ],
            "layout": "IPY_MODEL_f10f65b1cb0547928b1c7b87c6385de4"
          }
        },
        "b04abee189594c62b235e5076deafc84": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_bdeb6c6df5c049a69c0b613a42a69e35",
            "placeholder": "​",
            "style": "IPY_MODEL_565b8a229f66455886175a51a975878d",
            "value": "100%"
          }
        },
        "ff0cc2d2cf8f4009bd200fd17d7ba517": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_3491f280a58046518c5c28686cd80eb5",
            "max": 1716416,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_ef3de5b665104edcab59a1200259b897",
            "value": 1716416
          }
        },
        "49f821f89aa44034af5988b888734185": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_ed1d6f1156f748f8993dda1ee97f5caf",
            "placeholder": "​",
            "style": "IPY_MODEL_e84db532db0643fd81ff21364b3b2e53",
            "value": " 1.72M/1.72M [00:00&lt;00:00, 29.0MiB/s]"
          }
        },
        "f10f65b1cb0547928b1c7b87c6385de4": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "bdeb6c6df5c049a69c0b613a42a69e35": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "565b8a229f66455886175a51a975878d": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "3491f280a58046518c5c28686cd80eb5": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "ef3de5b665104edcab59a1200259b897": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "ed1d6f1156f748f8993dda1ee97f5caf": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "e84db532db0643fd81ff21364b3b2e53": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "48125358d93747af8d60adf49cb4bed3": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_ce66e5dab6a7433498679f44d7922fde",
              "IPY_MODEL_037cca2c146a429498219af57498f92d",
              "IPY_MODEL_a4dd416d3a3f400a958713c9e1338830"
            ],
            "layout": "IPY_MODEL_c98d82d69aa5436e86a00b3b24c71dc8"
          }
        },
        "ce66e5dab6a7433498679f44d7922fde": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_3e842df16ae04f7c9fa0500251ea6070",
            "placeholder": "​",
            "style": "IPY_MODEL_125527f8c490490f93c88276e8da441e",
            "value": "100%"
          }
        },
        "037cca2c146a429498219af57498f92d": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_38ea9e2fdf934b299dbf47b478f454cd",
            "max": 3288938,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_25123bc15acb4025a468103612181d4b",
            "value": 3288938
          }
        },
        "a4dd416d3a3f400a958713c9e1338830": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_38eadb841c66408ca51a85054a2da63c",
            "placeholder": "​",
            "style": "IPY_MODEL_283ef3c448dd4fb0baaa1621123a5ced",
            "value": " 3.29M/3.29M [00:00&lt;00:00, 9.27MiB/s]"
          }
        },
        "c98d82d69aa5436e86a00b3b24c71dc8": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "3e842df16ae04f7c9fa0500251ea6070": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "125527f8c490490f93c88276e8da441e": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "38ea9e2fdf934b299dbf47b478f454cd": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "25123bc15acb4025a468103612181d4b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "38eadb841c66408ca51a85054a2da63c": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "283ef3c448dd4fb0baaa1621123a5ced": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "0ee9d77e31c343d2b226c9e1c370899a": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_cefbf3ec854e463eac3047d7f2366a9b",
              "IPY_MODEL_5d5a04539517439c9a47f725bbfca641",
              "IPY_MODEL_487df5716a1f42b9ad08a05300882448"
            ],
            "layout": "IPY_MODEL_f6f95cf2eb1f43cdbb1be5a1ffc19621"
          }
        },
        "cefbf3ec854e463eac3047d7f2366a9b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_a8b2545d7d94490b8df9d8a63d7fde2d",
            "placeholder": "​",
            "style": "IPY_MODEL_18b7438e17ef4851aa9c8d0dfc52f2d5",
            "value": "Optimization Progress: 100%"
          }
        },
        "5d5a04539517439c9a47f725bbfca641": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_939ebe26aaf74df78c81c255aefcc7e5",
            "max": 20,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_c5677148554a4e65b74ae9fc95ae4c37",
            "value": 20
          }
        },
        "487df5716a1f42b9ad08a05300882448": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_328be8dce5cf4b2a8418e7693f1829c0",
            "placeholder": "​",
            "style": "IPY_MODEL_48d9d503aebd44578cb545fdb4b28776",
            "value": " 40/40 [02:13&lt;00:00,  2.60s/pipeline]"
          }
        },
        "f6f95cf2eb1f43cdbb1be5a1ffc19621": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": "hidden",
            "width": null
          }
        },
        "a8b2545d7d94490b8df9d8a63d7fde2d": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "18b7438e17ef4851aa9c8d0dfc52f2d5": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "939ebe26aaf74df78c81c255aefcc7e5": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "c5677148554a4e65b74ae9fc95ae4c37": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "328be8dce5cf4b2a8418e7693f1829c0": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "48d9d503aebd44578cb545fdb4b28776": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        }
      }
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# AutoML with TPOT using Adversary Emulation (C2) as datagen - Supervised and Deep Learning with Genetic Programming"
      ],
      "metadata": {
        "id": "YJeseKzwjOVm"
      }
    },
    {
      "cell_type": "markdown",
      "source": [],
      "metadata": {
        "id": "wUrhwXsDkETs"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Installations\n",
        "\n",
        "The installation is mostly automated.\n",
        "\n",
        "A file in the same directory named \"thesis_ro\" will be required, which should contain your GitHub read-only token.\n",
        "\n",
        "The file has one line:\n",
        "\n",
        "\n",
        "`echo \"GITHUB_PERSONAL_ACCESS_TOKEN=\"ghp_...\" > thesis_ro`"
      ],
      "metadata": {
        "id": "Fv4KCLz9j4Zc"
      }
    },
    {
      "cell_type": "code",
      "execution_count": 8,
      "metadata": {
        "id": "ayxWRSxzgwh_"
      },
      "outputs": [],
      "source": [
        "import sys\n",
        "import os\n",
        "import subprocess\n",
        "\n",
        "IN_COLAB = 'google.colab' in sys.modules\n",
        "\n",
        "if not IN_COLAB:\n",
        "  pass\n",
        "\n",
        "else:\n",
        "  subprocess.run('''\n",
        "    source <(curl -s https://raw.githubusercontent.com/norandom/log2ml/main/dependencies/install.sh)\n",
        "    ''',\n",
        "    shell=True, check=True, executable='/bin/bash')\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "from dotenv import load_dotenv\n",
        "import os\n",
        "\n",
        "load_dotenv(\"thesis_ro\", verbose=True)  # take environment variables from the file\n",
        "token = os.getenv('GITHUB_PERSONAL_ACCESS_TOKEN')\n",
        "if len(token) > 0:\n",
        "  print(\"ok\")\n",
        "else:\n",
        "  print(\"no token\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "vyKWa35bkFcG",
        "outputId": "afaf2961-374c-4ced-ba84-a8eb74963834"
      },
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "ok\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Data download: captured Sysmon logs from the AE lab\n",
        "\n",
        "These samples contain Sysmon log activity of Dropper Malware (C2 Dropper, MS Excel VBA, Covenant).\n",
        "\n",
        "No AE campaigns, just the Dropper itself.\n",
        "\n",
        "We are looking at 1000 documents, some malicious and some not. Which ones are malicious? How does the VBA Excel malware behave? How not? Can ML help to find out?"
      ],
      "metadata": {
        "id": "oYVNy4rNojZc"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from github import Github\n",
        "import requests\n",
        "from tqdm.notebook import tqdm\n",
        "\n",
        "\n",
        "def get_specific_file_from_tagged_release(token, repo_name, tag_name, filename):\n",
        "    g = Github(token)\n",
        "    repo = g.get_repo(repo_name)\n",
        "    releases = repo.get_releases()\n",
        "\n",
        "    for release in releases:\n",
        "        if release.tag_name == tag_name:\n",
        "            for asset in release.get_assets():\n",
        "                if asset.name == filename:\n",
        "                    return asset.url\n",
        "    print(\"File not found. Try get_specific_file_from_latest_release() instead.\")\n",
        "    return None\n",
        "\n",
        "def get_specific_file_from_latest_release(token, repo_name, filename):\n",
        "    g = Github(token)\n",
        "    repo = g.get_repo(repo_name)\n",
        "    release = repo.get_latest_release()\n",
        "\n",
        "    for asset in release.get_assets():\n",
        "        if asset.name == filename:\n",
        "            return asset.url  # Use asset.url which points to API URL needing headers\n",
        "\n",
        "def download_file(url, token, save_path):\n",
        "    headers = {'Authorization': f'token {token}', 'Accept': 'application/octet-stream'}\n",
        "    # First request to handle GitHub's redirection and authentication properly\n",
        "    with requests.get(url, headers=headers, stream=True) as initial_response:\n",
        "        initial_response.raise_for_status()  # Ensure the initial request is successful\n",
        "        # Follow redirection if necessary, maintaining headers\n",
        "        if initial_response.history:\n",
        "            url = initial_response.url  # Updated URL after redirection\n",
        "\n",
        "        # Now, proceed with downloading the file\n",
        "        with requests.get(url, headers=headers, stream=True) as response:\n",
        "            response.raise_for_status()\n",
        "            total_size_in_bytes = int(response.headers.get('content-length', 0))\n",
        "            block_size = 1024\n",
        "\n",
        "            progress_bar = tqdm(total=total_size_in_bytes, unit='iB', unit_scale=True)\n",
        "            with open(save_path, 'wb') as file:\n",
        "                for data in response.iter_content(block_size):\n",
        "                    progress_bar.update(len(data))\n",
        "                    file.write(data)\n",
        "            progress_bar.close()\n",
        "\n",
        "            if total_size_in_bytes != 0 and progress_bar.n != total_size_in_bytes:\n",
        "                print(\"ERROR, something went wrong\")\n",
        "            else:\n",
        "                print(f\"File downloaded successfully and saved as {save_path}\")\n",
        "\n",
        "# Your GitHub token\n",
        "github_token = token\n",
        "\n",
        "# Repository name\n",
        "repository_name = \"norandom/log2ml\"\n",
        "\n",
        "# File name to search for\n",
        "file_name = \"lab_logs_blindtest_activity_sysmon_1000samples_july_28_2024.csv\"\n",
        "\n",
        "# Get the download URL of the specific file\n",
        "# download_url = get_specific_file_from_latest_release(github_token, repository_name, file_name)\n",
        "download_url = get_specific_file_from_tagged_release(github_token, repository_name, \"lab\", file_name)\n",
        "print(download_url)\n",
        "\n",
        "if download_url:\n",
        "    local_file_path = file_name\n",
        "    download_file(download_url, github_token, local_file_path)\n",
        "else:\n",
        "    print(\"File not found.\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 85,
          "referenced_widgets": [
            "d35be0ff26cc4d0e85b498638ec728da",
            "6c3982ed895846f2a07befc28277debd",
            "a031633d17474670a3055d94249d58ee",
            "08d30171bbb44668aea730cc7e2e828a",
            "bda89cfac064435b8de02f41e689e0a3",
            "603fa104247d4ae8888440acca48221e",
            "bf6290dc87bd447da28102899e57ffe5",
            "fe8beb6587574f93a2947c2bcc907091",
            "3b5d864ced1149c4979b491cbc3070f7",
            "e2306dc620194ce485bd2663c7d25738",
            "329389fea5f74dca965f296707c2a8d0"
          ]
        },
        "id": "5EEoa3gUmFpn",
        "outputId": "806090b8-b3d5-473b-9da5-52de1860cb00"
      },
      "execution_count": 10,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "https://api.github.com/repos/norandom/log2ml/releases/assets/182477524\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "  0%|          | 0.00/8.04M [00:00<?, ?iB/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "d35be0ff26cc4d0e85b498638ec728da"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "File downloaded successfully and saved as lab_logs_blindtest_activity_sysmon_1000samples_july_28_2024.csv\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Download pre-trained BPE Tokenizer from the project"
      ],
      "metadata": {
        "id": "Uyn6jyZvMsQI"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# File name to search for\n",
        "file_name = \"log_tokenizer.json\"\n",
        "\n",
        "# Get the download URL of the specific file\n",
        "# download_url = get_specific_file_from_latest_release(github_token, repository_name, file_name)\n",
        "download_url = get_specific_file_from_tagged_release(github_token, repository_name, \"lab\", file_name)\n",
        "print(download_url)\n",
        "\n",
        "if download_url:\n",
        "    local_file_path = file_name\n",
        "    download_file(download_url, github_token, local_file_path)\n",
        "else:\n",
        "    print(\"File not found.\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 85,
          "referenced_widgets": [
            "9d26aed57a8244ada934039dd928555c",
            "b04abee189594c62b235e5076deafc84",
            "ff0cc2d2cf8f4009bd200fd17d7ba517",
            "49f821f89aa44034af5988b888734185",
            "f10f65b1cb0547928b1c7b87c6385de4",
            "bdeb6c6df5c049a69c0b613a42a69e35",
            "565b8a229f66455886175a51a975878d",
            "3491f280a58046518c5c28686cd80eb5",
            "ef3de5b665104edcab59a1200259b897",
            "ed1d6f1156f748f8993dda1ee97f5caf",
            "e84db532db0643fd81ff21364b3b2e53"
          ]
        },
        "id": "PA-8JXLyn4Uv",
        "outputId": "1850bb3e-a2bc-4cf0-d988-98f3986e2ab1"
      },
      "execution_count": 75,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "https://api.github.com/repos/norandom/log2ml/releases/assets/182534935\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "  0%|          | 0.00/1.72M [00:00<?, ?iB/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "9d26aed57a8244ada934039dd928555c"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "File downloaded successfully and saved as log_tokenizer.json\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Download pre-vecorized data from the project"
      ],
      "metadata": {
        "id": "rTw3shjR33yL"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# File name to search for\n",
        "file_name = \"lab_logs_blindtest_activity_sysmon_1000samples_july_28_2024_filtered_vectors.parquet\"\n",
        "\n",
        "# Get the download URL of the specific file\n",
        "# download_url = get_specific_file_from_latest_release(github_token, repository_name, file_name)\n",
        "download_url = get_specific_file_from_tagged_release(github_token, repository_name, \"lab\", file_name)\n",
        "print(download_url)\n",
        "\n",
        "if download_url:\n",
        "    local_file_path = file_name\n",
        "    download_file(download_url, github_token, local_file_path)\n",
        "else:\n",
        "    print(\"File not found.\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 85,
          "referenced_widgets": [
            "48125358d93747af8d60adf49cb4bed3",
            "ce66e5dab6a7433498679f44d7922fde",
            "037cca2c146a429498219af57498f92d",
            "a4dd416d3a3f400a958713c9e1338830",
            "c98d82d69aa5436e86a00b3b24c71dc8",
            "3e842df16ae04f7c9fa0500251ea6070",
            "125527f8c490490f93c88276e8da441e",
            "38ea9e2fdf934b299dbf47b478f454cd",
            "25123bc15acb4025a468103612181d4b",
            "38eadb841c66408ca51a85054a2da63c",
            "283ef3c448dd4fb0baaa1621123a5ced"
          ]
        },
        "id": "WdRLtddt378k",
        "outputId": "58f22716-5958-4cf4-a2d4-eff7384b87cc"
      },
      "execution_count": 11,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "https://api.github.com/repos/norandom/log2ml/releases/assets/182698628\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "  0%|          | 0.00/3.29M [00:00<?, ?iB/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "48125358d93747af8d60adf49cb4bed3"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "File downloaded successfully and saved as lab_logs_blindtest_activity_sysmon_1000samples_july_28_2024_filtered_vectors.parquet\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# ETL and labeling"
      ],
      "metadata": {
        "id": "qM4Ym_5Zon4w"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import polars as pl\n",
        "\n",
        "csv_file_path = 'lab_logs_blindtest_activity_sysmon_1000samples_july_28_2024.csv'\n",
        "\n",
        "# Load the CSV file into a DataFrame\n",
        "df = pl.read_csv(csv_file_path)\n",
        "\n",
        "# Show the DataFrame to confirm it's loaded correctly\n",
        "print(df)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "SCKEWW-aoNDQ",
        "outputId": "058d265e-3989-4641-86fa-3d518efbb04a"
      },
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "shape: (13_455, 7)\n",
            "┌──────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┐\n",
            "│ @timestamp   ┆ host.hostna ┆ host.ip     ┆ log.level   ┆ winlog.even ┆ winlog.task ┆ message     │\n",
            "│ ---          ┆ me          ┆ ---         ┆ ---         ┆ t_id        ┆ ---         ┆ ---         │\n",
            "│ str          ┆ ---         ┆ str         ┆ str         ┆ ---         ┆ str         ┆ str         │\n",
            "│              ┆ str         ┆             ┆             ┆ i64         ┆             ┆             │\n",
            "╞══════════════╪═════════════╪═════════════╪═════════════╪═════════════╪═════════════╪═════════════╡\n",
            "│ 2024-07-28T1 ┆ win10       ┆ fe80::c1af: ┆ information ┆ 13          ┆ Registry    ┆ Registry    │\n",
            "│ 5:09:33.716Z ┆             ┆ 35de:6006:d ┆             ┆             ┆ value set   ┆ value set:  │\n",
            "│              ┆             ┆ 4cf         ┆             ┆             ┆ (rule:      ┆ RuleName:   │\n",
            "│              ┆             ┆             ┆             ┆             ┆ Regist…     ┆ In…         │\n",
            "│ 2024-07-28T1 ┆ win10       ┆ fe80::c1af: ┆ information ┆ 1           ┆ Process     ┆ Process     │\n",
            "│ 5:09:33.932Z ┆             ┆ 35de:6006:d ┆             ┆             ┆ Create      ┆ Create:     │\n",
            "│              ┆             ┆ 4cf         ┆             ┆             ┆ (rule:      ┆ RuleName: - │\n",
            "│              ┆             ┆             ┆             ┆             ┆ ProcessCre… ┆ UtcT…       │\n",
            "│ 2024-07-28T1 ┆ win10       ┆ fe80::c1af: ┆ information ┆ 11          ┆ File        ┆ File        │\n",
            "│ 5:09:34.154Z ┆             ┆ 35de:6006:d ┆             ┆             ┆ created     ┆ created:    │\n",
            "│              ┆             ┆ 4cf         ┆             ┆             ┆ (rule:      ┆ RuleName:   │\n",
            "│              ┆             ┆             ┆             ┆             ┆ FileCreate) ┆ EXE         │\n",
            "│              ┆             ┆             ┆             ┆             ┆             ┆ UtcT…       │\n",
            "│ 2024-07-28T1 ┆ win10       ┆ fe80::c1af: ┆ information ┆ 11          ┆ File        ┆ File        │\n",
            "│ 5:09:34.154Z ┆             ┆ 35de:6006:d ┆             ┆             ┆ created     ┆ created:    │\n",
            "│              ┆             ┆ 4cf         ┆             ┆             ┆ (rule:      ┆ RuleName:   │\n",
            "│              ┆             ┆             ┆             ┆             ┆ FileCreate) ┆ EXE         │\n",
            "│              ┆             ┆             ┆             ┆             ┆             ┆ UtcT…       │\n",
            "│ …            ┆ …           ┆ …           ┆ …           ┆ …           ┆ …           ┆ …           │\n",
            "│ 2024-07-28T2 ┆ win10       ┆ fe80::c1af: ┆ information ┆ 5           ┆ Process     ┆ Process     │\n",
            "│ 1:14:59.942Z ┆             ┆ 35de:6006:d ┆             ┆             ┆ terminated  ┆ terminated: │\n",
            "│              ┆             ┆ 4cf         ┆             ┆             ┆ (rule:      ┆ RuleName: - │\n",
            "│              ┆             ┆             ┆             ┆             ┆ Proces…     ┆ …           │\n",
            "│ 2024-07-28T2 ┆ win10       ┆ fe80::c1af: ┆ information ┆ 22          ┆ Dns query   ┆ Dns query:  │\n",
            "│ 1:14:46.543Z ┆             ┆ 35de:6006:d ┆             ┆             ┆ (rule:      ┆ RuleName: - │\n",
            "│              ┆             ┆ 4cf         ┆             ┆             ┆ DnsQuery)   ┆ UtcTime: …  │\n",
            "│ 2024-07-28T2 ┆ win10       ┆ fe80::c1af: ┆ information ┆ 10          ┆ Process     ┆ Process     │\n",
            "│ 1:15:26.859Z ┆             ┆ 35de:6006:d ┆             ┆             ┆ accessed    ┆ accessed:   │\n",
            "│              ┆             ┆ 4cf         ┆             ┆             ┆ (rule:      ┆ RuleName: - │\n",
            "│              ┆             ┆             ┆             ┆             ┆ ProcessA…   ┆ Ut…         │\n",
            "│ 2024-07-28T2 ┆ win10       ┆ fe80::c1af: ┆ information ┆ 22          ┆ Dns query   ┆ Dns query:  │\n",
            "│ 1:15:29.929Z ┆             ┆ 35de:6006:d ┆             ┆             ┆ (rule:      ┆ RuleName: - │\n",
            "│              ┆             ┆ 4cf         ┆             ┆             ┆ DnsQuery)   ┆ UtcTime: …  │\n",
            "└──────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────┘\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Sorting the data\n",
        "\n",
        "By defeault Elasticsearch sorts the data based on when it was received. Not based on the log timestamp."
      ],
      "metadata": {
        "id": "tKBQ5qsaBH02"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# sort data\n",
        "\n",
        "# Convert @timestamp to timestamp type\n",
        "df = df.with_columns(\n",
        "    pl.col(\"@timestamp\").str.to_datetime()\n",
        ")\n",
        "\n",
        "\n",
        "df = df.sort(\"@timestamp\")"
      ],
      "metadata": {
        "id": "Dzc4ZwG0NcMQ"
      },
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Denoised vector generation\n",
        "\n",
        "Here system specific strings get removed. This improves the transferability."
      ],
      "metadata": {
        "id": "cYjpfMq1qKb1"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "def remove_keyword_lines(batch, keywords):\n",
        "    def modify_message(message):\n",
        "        lines = message.split('\\n')\n",
        "        processed_lines = []\n",
        "        processed_keywords = set()\n",
        "\n",
        "        for line in lines:\n",
        "            processed = False\n",
        "            for keyword in keywords:\n",
        "                if line.startswith(f\"{keyword}:\") and keyword not in processed_keywords:\n",
        "                    processed_keywords.add(keyword)\n",
        "                    if keyword == 'User':\n",
        "                        parts = line.split('\\\\')\n",
        "                        if len(parts) > 1:\n",
        "                            processed_lines.append(f\"User: {parts[1]}\")\n",
        "                    elif keyword in ['SourceHostname', 'DestinationHostname']:\n",
        "                        parts = line.split(':', 1)\n",
        "                        if len(parts) > 1:\n",
        "                            hostname = parts[1].strip().split('.')[0]\n",
        "                            processed_lines.append(f\"{keyword}: {hostname}\")\n",
        "                    elif keyword == 'QueryName':\n",
        "                        parts = line.split(':', 1)\n",
        "                        if len(parts) > 1:\n",
        "                            domain = parts[1].strip().split('.')\n",
        "                            if len(domain) > 0:\n",
        "                                processed_lines.append(f\"QueryName: {domain[0]}\")\n",
        "                    else:\n",
        "                        processed_lines.append(line)\n",
        "                    processed = True\n",
        "                    break\n",
        "            if not processed:\n",
        "                processed_lines.append(line)\n",
        "\n",
        "        return '\\n'.join(processed_lines)\n",
        "\n",
        "    return batch.map_elements(modify_message, return_dtype=pl.Utf8)\n",
        "\n",
        "# Keywords to filter or process\n",
        "keywords_to_filter = [\"UtcTime\", \"SourceProcessGUID\", \"ProcessGuid\", \"TargetProcessGUID\", \"TargetObject\", \"FileVersion\", \"Hashes\", \"LogonGuid\", \"LogonId\", \"CreationUtcTime\", \"User\", \"ParentProcessGuid\", \"SourceHostname\", \"DestinationHostname\", \"QueryName\"]\n",
        "\n",
        "# Apply the transformation to the 'message' column using map_batches\n",
        "df_f = df.with_columns(\n",
        "    pl.col(\"message\").map_batches(lambda batch: remove_keyword_lines(batch, keywords_to_filter), return_dtype=pl.Utf8).alias(\"filtered_message\")\n",
        ")\n",
        "\n",
        "# Show the DataFrame to confirm it's loaded correctly\n",
        "print(df_f)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "_CJUqGQUqFew",
        "outputId": "19a5362a-01dd-4208-f7f0-93f019ac6738"
      },
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "shape: (13_455, 8)\n",
            "┌────────────┬────────────┬────────────┬───────────┬───────────┬───────────┬───────────┬───────────┐\n",
            "│ @timestamp ┆ host.hostn ┆ host.ip    ┆ log.level ┆ winlog.ev ┆ winlog.ta ┆ message   ┆ filtered_ │\n",
            "│ ---        ┆ ame        ┆ ---        ┆ ---       ┆ ent_id    ┆ sk        ┆ ---       ┆ message   │\n",
            "│ datetime[μ ┆ ---        ┆ str        ┆ str       ┆ ---       ┆ ---       ┆ str       ┆ ---       │\n",
            "│ s, UTC]    ┆ str        ┆            ┆           ┆ i64       ┆ str       ┆           ┆ str       │\n",
            "╞════════════╪════════════╪════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informati ┆ 3         ┆ Network   ┆ Network   ┆ Network   │\n",
            "│ 15:08:24.2 ┆            ┆ :35de:6006 ┆ on        ┆           ┆ connectio ┆ connectio ┆ connectio │\n",
            "│ 77 UTC     ┆            ┆ :d4cf      ┆           ┆           ┆ n         ┆ n         ┆ n         │\n",
            "│            ┆            ┆            ┆           ┆           ┆ detected  ┆ detected: ┆ detected: │\n",
            "│            ┆            ┆            ┆           ┆           ┆ (rul…     ┆ Rul…      ┆ Rul…      │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informati ┆ 3         ┆ Network   ┆ Network   ┆ Network   │\n",
            "│ 15:08:24.4 ┆            ┆ :35de:6006 ┆ on        ┆           ┆ connectio ┆ connectio ┆ connectio │\n",
            "│ 88 UTC     ┆            ┆ :d4cf      ┆           ┆           ┆ n         ┆ n         ┆ n         │\n",
            "│            ┆            ┆            ┆           ┆           ┆ detected  ┆ detected: ┆ detected: │\n",
            "│            ┆            ┆            ┆           ┆           ┆ (rul…     ┆ Rul…      ┆ Rul…      │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informati ┆ 10        ┆ Process   ┆ Process   ┆ Process   │\n",
            "│ 15:08:25.0 ┆            ┆ :35de:6006 ┆ on        ┆           ┆ accessed  ┆ accessed: ┆ accessed: │\n",
            "│ 05 UTC     ┆            ┆ :d4cf      ┆           ┆           ┆ (rule:    ┆ RuleName: ┆ RuleName: │\n",
            "│            ┆            ┆            ┆           ┆           ┆ ProcessA… ┆ -         ┆ -         │\n",
            "│            ┆            ┆            ┆           ┆           ┆           ┆ Ut…       ┆ Ut…       │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informati ┆ 10        ┆ Process   ┆ Process   ┆ Process   │\n",
            "│ 15:08:25.0 ┆            ┆ :35de:6006 ┆ on        ┆           ┆ accessed  ┆ accessed: ┆ accessed: │\n",
            "│ 05 UTC     ┆            ┆ :d4cf      ┆           ┆           ┆ (rule:    ┆ RuleName: ┆ RuleName: │\n",
            "│            ┆            ┆            ┆           ┆           ┆ ProcessA… ┆ -         ┆ -         │\n",
            "│            ┆            ┆            ┆           ┆           ┆           ┆ Ut…       ┆ Ut…       │\n",
            "│ …          ┆ …          ┆ …          ┆ …         ┆ …         ┆ …         ┆ …         ┆ …         │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informati ┆ 10        ┆ Process   ┆ Process   ┆ Process   │\n",
            "│ 23:35:53.0 ┆            ┆ :35de:6006 ┆ on        ┆           ┆ accessed  ┆ accessed: ┆ accessed: │\n",
            "│ 54 UTC     ┆            ┆ :d4cf      ┆           ┆           ┆ (rule:    ┆ RuleName: ┆ RuleName: │\n",
            "│            ┆            ┆            ┆           ┆           ┆ ProcessA… ┆ -         ┆ -         │\n",
            "│            ┆            ┆            ┆           ┆           ┆           ┆ Ut…       ┆ Ut…       │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informati ┆ 10        ┆ Process   ┆ Process   ┆ Process   │\n",
            "│ 23:35:54.1 ┆            ┆ :35de:6006 ┆ on        ┆           ┆ accessed  ┆ accessed: ┆ accessed: │\n",
            "│ 33 UTC     ┆            ┆ :d4cf      ┆           ┆           ┆ (rule:    ┆ RuleName: ┆ RuleName: │\n",
            "│            ┆            ┆            ┆           ┆           ┆ ProcessA… ┆ -         ┆ -         │\n",
            "│            ┆            ┆            ┆           ┆           ┆           ┆ Ut…       ┆ Ut…       │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informati ┆ 10        ┆ Process   ┆ Process   ┆ Process   │\n",
            "│ 23:35:54.1 ┆            ┆ :35de:6006 ┆ on        ┆           ┆ accessed  ┆ accessed: ┆ accessed: │\n",
            "│ 33 UTC     ┆            ┆ :d4cf      ┆           ┆           ┆ (rule:    ┆ RuleName: ┆ RuleName: │\n",
            "│            ┆            ┆            ┆           ┆           ┆ ProcessA… ┆ -         ┆ -         │\n",
            "│            ┆            ┆            ┆           ┆           ┆           ┆ Ut…       ┆ Ut…       │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informati ┆ 1         ┆ Process   ┆ Process   ┆ Process   │\n",
            "│ 23:41:55.3 ┆            ┆ :35de:6006 ┆ on        ┆           ┆ Create    ┆ Create:   ┆ Create:   │\n",
            "│ 01 UTC     ┆            ┆ :d4cf      ┆           ┆           ┆ (rule:    ┆ RuleName: ┆ RuleName: │\n",
            "│            ┆            ┆            ┆           ┆           ┆ ProcessCr ┆ -         ┆ -         │\n",
            "│            ┆            ┆            ┆           ┆           ┆ e…        ┆ UtcT…     ┆ UtcT…     │\n",
            "└────────────┴────────────┴────────────┴───────────┴───────────┴───────────┴───────────┴───────────┘\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import re\n",
        "\n",
        "# Extract relevant information using regular expressions\n",
        "def extract_info(text):\n",
        "    image = re.search(r\"Image: (.*?\\.exe)\", text, re.IGNORECASE)\n",
        "    target_filename = re.search(r\"TargetFilename: (.*?\\.exe)\", text, re.IGNORECASE)\n",
        "    parent_image = re.search(r\"ParentImage: (.*?\\.exe)\", text, re.IGNORECASE)\n",
        "\n",
        "    return {\n",
        "        \"image\": image.group(1) if image else \"\",\n",
        "        \"target_filename\": target_filename.group(1) if target_filename else \"\",\n",
        "        \"parent_image\": parent_image.group(1).split(\"\\\\\")[-1] if parent_image else \"\",\n",
        "        \"text\": text\n",
        "    }\n",
        "\n",
        "# Apply extraction to the Polars DataFrame using map_elements\n",
        "df_f = df_f.with_columns(\n",
        "    pl.col(\"filtered_message\").map_elements(lambda x: extract_info(x), return_dtype=pl.Object).alias(\"extracted_info\")\n",
        ")\n",
        "\n",
        "# Extract fields from the extracted_info column using map_elements with return_dtype\n",
        "df_f = df_f.with_columns(\n",
        "    pl.col(\"extracted_info\").map_elements(lambda x: x['image'], return_dtype=pl.Utf8).alias(\"image\"),\n",
        "    pl.col(\"extracted_info\").map_elements(lambda x: x['target_filename'], return_dtype=pl.Utf8).alias(\"target_filename\"),\n",
        "    pl.col(\"extracted_info\").map_elements(lambda x: x['parent_image'], return_dtype=pl.Utf8).alias(\"parent_image\"),\n",
        "    pl.col(\"extracted_info\").map_elements(lambda x: x['text'], return_dtype=pl.Utf8).alias(\"text\")\n",
        ").drop(\"extracted_info\")\n",
        "\n",
        "print(df_f.head())\n",
        "\n",
        "# Print the unique values in the parent_image column\n",
        "print(df_f[\"parent_image\"].value_counts())\n",
        "print(df_f[\"target_filename\"].value_counts())"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "WBy3Rqj_orz_",
        "outputId": "619326ed-d925-4816-cae6-c1a0274d8a43"
      },
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "shape: (5, 12)\n",
            "┌───────────┬───────────┬───────────┬───────────┬───┬───────────┬───────────┬───────────┬──────────┐\n",
            "│ @timestam ┆ host.host ┆ host.ip   ┆ log.level ┆ … ┆ image     ┆ target_fi ┆ parent_im ┆ text     │\n",
            "│ p         ┆ name      ┆ ---       ┆ ---       ┆   ┆ ---       ┆ lename    ┆ age       ┆ ---      │\n",
            "│ ---       ┆ ---       ┆ str       ┆ str       ┆   ┆ str       ┆ ---       ┆ ---       ┆ str      │\n",
            "│ datetime[ ┆ str       ┆           ┆           ┆   ┆           ┆ str       ┆ str       ┆          │\n",
            "│ μs, UTC]  ┆           ┆           ┆           ┆   ┆           ┆           ┆           ┆          │\n",
            "╞═══════════╪═══════════╪═══════════╪═══════════╪═══╪═══════════╪═══════════╪═══════════╪══════════╡\n",
            "│ 2024-07-2 ┆ win10     ┆ fe80::c1a ┆ informati ┆ … ┆ C:\\Window ┆           ┆           ┆ Network  │\n",
            "│ 8 15:08:2 ┆           ┆ f:35de:60 ┆ on        ┆   ┆ s\\System3 ┆           ┆           ┆ connecti │\n",
            "│ 4.277 UTC ┆           ┆ 06:d4cf   ┆           ┆   ┆ 2\\svchost ┆           ┆           ┆ on detec │\n",
            "│           ┆           ┆           ┆           ┆   ┆ .exe      ┆           ┆           ┆ ted:     │\n",
            "│           ┆           ┆           ┆           ┆   ┆           ┆           ┆           ┆ Rul…     │\n",
            "│ 2024-07-2 ┆ win10     ┆ fe80::c1a ┆ informati ┆ … ┆ C:\\Window ┆           ┆           ┆ Network  │\n",
            "│ 8 15:08:2 ┆           ┆ f:35de:60 ┆ on        ┆   ┆ s\\System3 ┆           ┆           ┆ connecti │\n",
            "│ 4.488 UTC ┆           ┆ 06:d4cf   ┆           ┆   ┆ 2\\svchost ┆           ┆           ┆ on detec │\n",
            "│           ┆           ┆           ┆           ┆   ┆ .exe      ┆           ┆           ┆ ted:     │\n",
            "│           ┆           ┆           ┆           ┆   ┆           ┆           ┆           ┆ Rul…     │\n",
            "│ 2024-07-2 ┆ win10     ┆ fe80::c1a ┆ informati ┆ … ┆ C:\\Window ┆           ┆           ┆ Process  │\n",
            "│ 8 15:08:2 ┆           ┆ f:35de:60 ┆ on        ┆   ┆ s\\system3 ┆           ┆           ┆ accessed │\n",
            "│ 5.005 UTC ┆           ┆ 06:d4cf   ┆           ┆   ┆ 2\\svchost ┆           ┆           ┆ :        │\n",
            "│           ┆           ┆           ┆           ┆   ┆ .exe      ┆           ┆           ┆ RuleName │\n",
            "│           ┆           ┆           ┆           ┆   ┆           ┆           ┆           ┆ : -      │\n",
            "│           ┆           ┆           ┆           ┆   ┆           ┆           ┆           ┆ Ut…      │\n",
            "│ 2024-07-2 ┆ win10     ┆ fe80::c1a ┆ informati ┆ … ┆ C:\\Window ┆           ┆           ┆ Process  │\n",
            "│ 8 15:08:2 ┆           ┆ f:35de:60 ┆ on        ┆   ┆ s\\system3 ┆           ┆           ┆ accessed │\n",
            "│ 5.005 UTC ┆           ┆ 06:d4cf   ┆           ┆   ┆ 2\\svchost ┆           ┆           ┆ :        │\n",
            "│           ┆           ┆           ┆           ┆   ┆ .exe      ┆           ┆           ┆ RuleName │\n",
            "│           ┆           ┆           ┆           ┆   ┆           ┆           ┆           ┆ : -      │\n",
            "│           ┆           ┆           ┆           ┆   ┆           ┆           ┆           ┆ Ut…      │\n",
            "│ 2024-07-2 ┆ win10     ┆ fe80::c1a ┆ informati ┆ … ┆ C:\\Window ┆           ┆           ┆ Process  │\n",
            "│ 8 15:08:2 ┆           ┆ f:35de:60 ┆ on        ┆   ┆ s\\system3 ┆           ┆           ┆ accessed │\n",
            "│ 5.030 UTC ┆           ┆ 06:d4cf   ┆           ┆   ┆ 2\\svchost ┆           ┆           ┆ :        │\n",
            "│           ┆           ┆           ┆           ┆   ┆ .exe      ┆           ┆           ┆ RuleName │\n",
            "│           ┆           ┆           ┆           ┆   ┆           ┆           ┆           ┆ : -      │\n",
            "│           ┆           ┆           ┆           ┆   ┆           ┆           ┆           ┆ Ut…      │\n",
            "└───────────┴───────────┴───────────┴───────────┴───┴───────────┴───────────┴───────────┴──────────┘\n",
            "shape: (41, 2)\n",
            "┌─────────────────────┬───────┐\n",
            "│ parent_image        ┆ count │\n",
            "│ ---                 ┆ ---   │\n",
            "│ str                 ┆ u32   │\n",
            "╞═════════════════════╪═══════╡\n",
            "│ pip.exe             ┆ 9     │\n",
            "│ Ec2Config.exe       ┆ 2     │\n",
            "│ CompatTelRunner.exe ┆ 2     │\n",
            "│ PLUGScheduler.exe   ┆ 2     │\n",
            "│ …                   ┆ …     │\n",
            "│ AvLaunch.exe        ┆ 1     │\n",
            "│ AvastSvc.exe        ┆ 7     │\n",
            "│ EXCEL.EXE           ┆ 116   │\n",
            "│ Update.exe          ┆ 1     │\n",
            "└─────────────────────┴───────┘\n",
            "shape: (91, 2)\n",
            "┌───────────────────────────────────┬───────┐\n",
            "│ target_filename                   ┆ count │\n",
            "│ ---                               ┆ ---   │\n",
            "│ str                               ┆ u32   │\n",
            "╞═══════════════════════════════════╪═══════╡\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ 1     │\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ 1     │\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ 1     │\n",
            "│ C:\\Program Files (x86)\\Microsoft… ┆ 1     │\n",
            "│ …                                 ┆ …     │\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ 1     │\n",
            "│ C:\\Program Files\\WindowsApps\\Mic… ┆ 1     │\n",
            "│ C:\\Users\\student\\AppData\\Local\\M… ┆ 1     │\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ 1     │\n",
            "└───────────────────────────────────┴───────┘\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "def is_temp_folder(path):\n",
        "    if not path:\n",
        "        return False\n",
        "\n",
        "    # Convert path to lowercase for case-insensitive comparison\n",
        "    lower_path = path.lower()\n",
        "\n",
        "    # Check if the path contains \"\\temp\\\" or ends with \"\\temp\"\n",
        "    if \"\\temp\\\\\" in lower_path or lower_path.endswith(\"\\\\temp\"):\n",
        "        return True\n",
        "\n",
        "    # Check for specific temp folder patterns\n",
        "    temp_patterns = [\n",
        "        r\"c:\\windows\\temp\",\n",
        "        r\"c:\\users\\*\\appdata\\local\\temp\",\n",
        "        r\"c:\\users\\*\\appdata\\locallow\\temp\",\n",
        "        r\"c:\\users\\*\\appdata\\roaming\\temp\",\n",
        "        r\"c:\\temp\",\n",
        "        r\"c:\\windows\\softwaredistriβution\\download\",\n",
        "    ]\n",
        "\n",
        "    for pattern in temp_patterns:\n",
        "        if pattern.startswith(r\"c:\\users\\*\"):\n",
        "            # Replace the wildcard with the actual username\n",
        "            user_pattern = pattern.replace(\"*\", path.split(\"\\\\\")[2])\n",
        "            if lower_path.startswith(user_pattern):\n",
        "                return True\n",
        "        elif lower_path.startswith(pattern):\n",
        "            return True\n",
        "\n",
        "    return False\n",
        "\n",
        "def get_filename(path):\n",
        "    return path.split(\"\\\\\")[-1] if path else \"\"\n",
        "\n",
        "# Add new columns to the DataFrame in a single operation\n",
        "df_f = df_f.with_columns([\n",
        "    pl.col(\"target_filename\").map_elements(lambda x: \"Yes\" if is_temp_folder(x) else \"No\").alias(\"temp_folder\"),\n",
        "    pl.col(\"target_filename\").map_elements(get_filename).alias(\"filename\")\n",
        "])\n",
        "\n",
        "# Print the first few rows where temp_folder is \"Yes\"\n",
        "print(df_f.filter(pl.col(\"temp_folder\") == \"Yes\").select([\"target_filename\", \"temp_folder\", \"filename\"]).head(10))\n",
        "\n",
        "# Print value counts for temp_folder column\n",
        "print(df_f[\"temp_folder\"].value_counts())"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "b0wLxKfzsg1e",
        "outputId": "6719c91c-42fd-447a-c1f1-d29737af744f"
      },
      "execution_count": 5,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "shape: (10, 3)\n",
            "┌───────────────────────────────────┬─────────────┬────────────────────────┐\n",
            "│ target_filename                   ┆ temp_folder ┆ filename               │\n",
            "│ ---                               ┆ ---         ┆ ---                    │\n",
            "│ str                               ┆ str         ┆ str                    │\n",
            "╞═══════════════════════════════════╪═════════════╪════════════════════════╡\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ Yes         ┆ file.exe               │\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ Yes         ┆ cli-32.exe             │\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ Yes         ┆ cli-64.exe             │\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ Yes         ┆ cli-arm64.exe          │\n",
            "│ …                                 ┆ …           ┆ …                      │\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ Yes         ┆ gui-64.exe             │\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ Yes         ┆ gui-arm64.exe          │\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ Yes         ┆ gui.exe                │\n",
            "│ C:\\Users\\student\\AppData\\Local\\T… ┆ Yes         ┆ wininst-10.0-amd64.exe │\n",
            "└───────────────────────────────────┴─────────────┴────────────────────────┘\n",
            "shape: (2, 2)\n",
            "┌─────────────┬───────┐\n",
            "│ temp_folder ┆ count │\n",
            "│ ---         ┆ ---   │\n",
            "│ str         ┆ u32   │\n",
            "╞═════════════╪═══════╡\n",
            "│ No          ┆ 13289 │\n",
            "│ Yes         ┆ 166   │\n",
            "└─────────────┴───────┘\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "count = df_f.filter((pl.col(\"temp_folder\") == \"Yes\") & pl.col(\"filename\").str.contains(\"file.exe\")).height\n",
        "print(count)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "uj7NV2wGPHi2",
        "outputId": "6cbee9fb-4710-4855-b556-c5fed2dfce7e"
      },
      "execution_count": 6,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "114\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Store the data as CSV and JSON"
      ],
      "metadata": {
        "id": "BGPg1RDmxMVE"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "df_f.write_csv(\"lab_logs_blindtest_activity_sysmon_1000samples_july_28_2024_filtered.csv\", include_header=True)"
      ],
      "metadata": {
        "id": "ngGJUIsXu5fL"
      },
      "execution_count": 7,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "df_f.write_json(\"lab_logs_blindtest_activity_sysmon_1000samples_july_28_2024_filtered.json\")"
      ],
      "metadata": {
        "id": "lRQS5xLTvpZv"
      },
      "execution_count": 8,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Labeling based on Python"
      ],
      "metadata": {
        "id": "GgFNrU80xQsF"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "def define_label(row):\n",
        "    conditions = {\n",
        "        (\"EXCEL.EXE\" in row['image'] and \".exe\" in row['target_filename'] and row['temp_folder'] == \"Yes\"): \"bad\",\n",
        "        (row['parent_image'] == \"EXCEL.EXE\" and row['temp_folder'] == \"Yes\" and row['image'].lower().endswith('.exe')): \"bad\",\n",
        "        # Add more conditions here if needed\n",
        "    }\n",
        "    return conditions.get(True, \"good\")\n",
        "\n",
        "# Apply the label to the DataFrame\n",
        "df_f = df_f.with_columns(pl.struct(df_f.columns).map_elements(define_label).alias(\"label\"))\n",
        "\n",
        "# Print the first few rows where the label is \"bad\"\n",
        "print(df_f.filter(pl.col(\"label\") == \"bad\").select([\"image\", \"parent_image\", \"target_filename\", \"temp_folder\", \"label\"]).head(10))\n",
        "\n",
        "# Print value counts for the label column\n",
        "print(df_f[\"label\"].value_counts())"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "X5ptzPnfxP9M",
        "outputId": "4ef582a3-b626-466e-e3f7-5adab909eb13"
      },
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "shape: (10, 5)\n",
            "┌──────────────────────────────┬──────────────┬──────────────────────────────┬─────────────┬───────┐\n",
            "│ image                        ┆ parent_image ┆ target_filename              ┆ temp_folder ┆ label │\n",
            "│ ---                          ┆ ---          ┆ ---                          ┆ ---         ┆ ---   │\n",
            "│ str                          ┆ str          ┆ str                          ┆ str         ┆ str   │\n",
            "╞══════════════════════════════╪══════════════╪══════════════════════════════╪═════════════╪═══════╡\n",
            "│ C:\\Program Files\\Microsoft   ┆              ┆ C:\\Users\\student\\AppData\\Loc ┆ Yes         ┆ bad   │\n",
            "│ Offic…                       ┆              ┆ al\\T…                        ┆             ┆       │\n",
            "│ C:\\Program Files\\Microsoft   ┆              ┆ C:\\Users\\student\\AppData\\Loc ┆ Yes         ┆ bad   │\n",
            "│ Offic…                       ┆              ┆ al\\T…                        ┆             ┆       │\n",
            "│ C:\\Program Files\\Microsoft   ┆              ┆ C:\\Users\\student\\AppData\\Loc ┆ Yes         ┆ bad   │\n",
            "│ Offic…                       ┆              ┆ al\\T…                        ┆             ┆       │\n",
            "│ C:\\Program Files\\Microsoft   ┆              ┆ C:\\Users\\student\\AppData\\Loc ┆ Yes         ┆ bad   │\n",
            "│ Offic…                       ┆              ┆ al\\T…                        ┆             ┆       │\n",
            "│ …                            ┆ …            ┆ …                            ┆ …           ┆ …     │\n",
            "│ C:\\Program Files\\Microsoft   ┆              ┆ C:\\Users\\student\\AppData\\Loc ┆ Yes         ┆ bad   │\n",
            "│ Offic…                       ┆              ┆ al\\T…                        ┆             ┆       │\n",
            "│ C:\\Program Files\\Microsoft   ┆              ┆ C:\\Users\\student\\AppData\\Loc ┆ Yes         ┆ bad   │\n",
            "│ Offic…                       ┆              ┆ al\\T…                        ┆             ┆       │\n",
            "│ C:\\Program Files\\Microsoft   ┆              ┆ C:\\Users\\student\\AppData\\Loc ┆ Yes         ┆ bad   │\n",
            "│ Offic…                       ┆              ┆ al\\T…                        ┆             ┆       │\n",
            "│ C:\\Program Files\\Microsoft   ┆              ┆ C:\\Users\\student\\AppData\\Loc ┆ Yes         ┆ bad   │\n",
            "│ Offic…                       ┆              ┆ al\\T…                        ┆             ┆       │\n",
            "└──────────────────────────────┴──────────────┴──────────────────────────────┴─────────────┴───────┘\n",
            "shape: (2, 2)\n",
            "┌───────┬───────┐\n",
            "│ label ┆ count │\n",
            "│ ---   ┆ ---   │\n",
            "│ str   ┆ u32   │\n",
            "╞═══════╪═══════╡\n",
            "│ bad   ┆ 114   │\n",
            "│ good  ┆ 13341 │\n",
            "└───────┴───────┘\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Filter the DataFrame for rows where label is \"bad\" and select specified columns\n",
        "bad_df = df_f.filter(pl.col(\"label\") == \"bad\").select([\n",
        "    \"image\", \"parent_image\", \"filename\", \"temp_folder\", \"label\"\n",
        "])\n",
        "\n",
        "# Write the filtered DataFrame to a CSV file\n",
        "bad_df.write_csv(\"bad.csv\")\n",
        "\n",
        "# Print the first 10 rows of the bad DataFrame\n",
        "print(bad_df.head(10))\n",
        "\n",
        "# Print the total count of \"bad\" rows\n",
        "total_bad_count = bad_df.shape[0]\n",
        "print(f\"\\nTotal number of 'bad' rows: {total_bad_count}\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "dRH3AReO_i5D",
        "outputId": "3f93ab3d-f474-486a-9434-7991efd54c4d"
      },
      "execution_count": 10,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "shape: (10, 5)\n",
            "┌───────────────────────────────────┬──────────────┬──────────┬─────────────┬───────┐\n",
            "│ image                             ┆ parent_image ┆ filename ┆ temp_folder ┆ label │\n",
            "│ ---                               ┆ ---          ┆ ---      ┆ ---         ┆ ---   │\n",
            "│ str                               ┆ str          ┆ str      ┆ str         ┆ str   │\n",
            "╞═══════════════════════════════════╪══════════════╪══════════╪═════════════╪═══════╡\n",
            "│ C:\\Program Files\\Microsoft Offic… ┆              ┆ file.exe ┆ Yes         ┆ bad   │\n",
            "│ C:\\Program Files\\Microsoft Offic… ┆              ┆ file.exe ┆ Yes         ┆ bad   │\n",
            "│ C:\\Program Files\\Microsoft Offic… ┆              ┆ file.exe ┆ Yes         ┆ bad   │\n",
            "│ C:\\Program Files\\Microsoft Offic… ┆              ┆ file.exe ┆ Yes         ┆ bad   │\n",
            "│ …                                 ┆ …            ┆ …        ┆ …           ┆ …     │\n",
            "│ C:\\Program Files\\Microsoft Offic… ┆              ┆ file.exe ┆ Yes         ┆ bad   │\n",
            "│ C:\\Program Files\\Microsoft Offic… ┆              ┆ file.exe ┆ Yes         ┆ bad   │\n",
            "│ C:\\Program Files\\Microsoft Offic… ┆              ┆ file.exe ┆ Yes         ┆ bad   │\n",
            "│ C:\\Program Files\\Microsoft Offic… ┆              ┆ file.exe ┆ Yes         ┆ bad   │\n",
            "└───────────────────────────────────┴──────────────┴──────────┴─────────────┴───────┘\n",
            "\n",
            "Total number of 'bad' rows: 114\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Vectorization with Linformer"
      ],
      "metadata": {
        "id": "9-1dkT2mQHvJ"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import torch\n",
        "torch.cuda.empty_cache()"
      ],
      "metadata": {
        "id": "_Vgi0rjn_RIn"
      },
      "execution_count": 11,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Linformer parameter 1:1 from the researchers\n",
        "# then the input_size is determined based on the max no. of tokens\n",
        "# the positional embedding flag is on by default\n",
        "\n",
        "from linformer_pytorch import LinformerLM\n",
        "import torch\n",
        "\n",
        "linformer_model = LinformerLM(\n",
        "        num_tokens=30000, # Number of tokens in the LM\n",
        "        input_size=700, # Dimension 1 of the input\n",
        "        channels=64, # Dimension 2 of the input\n",
        "        dim_d=None, # Overwrites the inner dim of the attention heads. If None, sticks with the recommended channels // nhead, as in the \"Attention is all you need\" paper\n",
        "        dim_k=128, # The second dimension of the P_bar matrix from the paper\n",
        "        dim_ff=128, # Dimension in the feed forward network\n",
        "        dropout_ff=0.15, # Dropout for feed forward network\n",
        "        nhead=4, # Number of attention heads\n",
        "        depth=2, # How many times to run the model\n",
        "        dropout=0.1, # How much dropout to apply to P_bar after softmax\n",
        "        activation=\"gelu\", # What activation to use. Currently, only gelu and relu supported, and only on ff network.\n",
        "        checkpoint_level=\"C0\", # What checkpoint level to use. For more information, see below.\n",
        "        parameter_sharing=\"layerwise\", # What level of parameter sharing to use. For more information, see below.\n",
        "        k_reduce_by_layer=0, # Going down `depth`, how much to reduce `dim_k` by, for the `E` and `F` matrices. Will have a minimum value of 1.\n",
        "        full_attention=False, # Use full attention instead, for O(n^2) time and space complexity. Included here just for comparison\n",
        "        include_ff=True, # Whether or not to include the Feed Forward layer\n",
        "        w_o_intermediate_dim=None, # If not None, have 2 w_o matrices, such that instead of `dim*nead,channels`, you have `dim*nhead,w_o_int`, and `w_o_int,channels`\n",
        "        emb_dim=128, # If you want the embedding dimension to be different than the channels for the Linformer\n",
        "        causal=False, # If you want this to be a causal Linformer, where the upper right of the P_bar matrix is masked out.\n",
        "        method=\"learnable\", # The method of how to perform the projection. Supported methods are 'convolution', 'learnable', and 'no_params'\n",
        "        ff_intermediate=None, # See the section below for more information\n",
        "        ).cuda()"
      ],
      "metadata": {
        "id": "SsW6vlQNQhAy"
      },
      "execution_count": 12,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Vectorize text column in the DataFrame"
      ],
      "metadata": {
        "id": "h4cuBLWrSNVs"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "print(df_f.columns)\n",
        "print(df_f[[\"label\", \"filtered_message\"]])\n",
        "\n",
        "import polars as pl\n",
        "import random\n",
        "\n",
        "bad_messages = df_f.filter(pl.col('label') == 'bad').select('filtered_message')\n",
        "good_messages = df_f.filter(pl.col('label') == 'good').select('filtered_message')\n",
        "\n",
        "random_bad_message = \"\"\n",
        "random_good_message = \"\"\n",
        "\n",
        "if bad_messages.height > 0:\n",
        "    # Get a random index\n",
        "    random_index = random.randint(0, bad_messages.height - 1)\n",
        "\n",
        "    # Select the message at that random index\n",
        "    random_bad_message = bad_messages.row(random_index)[0]\n",
        "    print(random_bad_message)\n",
        "else:\n",
        "    print(\"No bad messages labeled found.\")\n",
        "\n",
        "print(\"\\n\\n\")\n",
        "\n",
        "if good_messages.height > 0:\n",
        "    # Get a random index\n",
        "    random_index = random.randint(0, good_messages.height - 1)\n",
        "\n",
        "    # Select the message at that random index\n",
        "    random_good_message = good_messages.row(random_index)[0]\n",
        "    print(random_good_message)\n",
        "else:\n",
        "    print(\"No good messages labeled found.\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "4SguqPPKSdpJ",
        "outputId": "b873ab30-300f-4b23-bf61-f7ed5ced345d"
      },
      "execution_count": 123,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "['@timestamp', 'host.hostname', 'host.ip', 'log.level', 'winlog.event_id', 'winlog.task', 'message', 'filtered_message', 'image', 'target_filename', 'parent_image', 'text', 'temp_folder', 'filename', 'label', 'message_vector']\n",
            "shape: (13_455, 2)\n",
            "┌───────┬──────────────────────────────┐\n",
            "│ label ┆ filtered_message             │\n",
            "│ ---   ┆ ---                          │\n",
            "│ str   ┆ str                          │\n",
            "╞═══════╪══════════════════════════════╡\n",
            "│ good  ┆ Network connection detected: │\n",
            "│       ┆ Rul…                         │\n",
            "│ good  ┆ Network connection detected: │\n",
            "│       ┆ Rul…                         │\n",
            "│ good  ┆ Process accessed:            │\n",
            "│       ┆ RuleName: -                  │\n",
            "│       ┆ Ut…                          │\n",
            "│ good  ┆ Process accessed:            │\n",
            "│       ┆ RuleName: -                  │\n",
            "│       ┆ Ut…                          │\n",
            "│ …     ┆ …                            │\n",
            "│ good  ┆ Process accessed:            │\n",
            "│       ┆ RuleName: -                  │\n",
            "│       ┆ Ut…                          │\n",
            "│ good  ┆ Process accessed:            │\n",
            "│       ┆ RuleName: -                  │\n",
            "│       ┆ Ut…                          │\n",
            "│ good  ┆ Process accessed:            │\n",
            "│       ┆ RuleName: -                  │\n",
            "│       ┆ Ut…                          │\n",
            "│ good  ┆ Process Create:              │\n",
            "│       ┆ RuleName: -                  │\n",
            "│       ┆ UtcT…                        │\n",
            "└───────┴──────────────────────────────┘\n",
            "File created:\n",
            "RuleName: EXE\n",
            "UtcTime: 2024-07-28 21:54:31.900\n",
            "ProcessGuid: {18e8265a-be12-66a6-3010-000000004400}\n",
            "ProcessId: 1248\n",
            "Image: C:\\Program Files\\Microsoft Office\\Root\\Office16\\EXCEL.EXE\n",
            "TargetFilename: C:\\Users\\student\\AppData\\Local\\Temp\\file.exe\n",
            "CreationUtcTime: 2024-07-23 14:24:50.520\n",
            "\n",
            "\n",
            "\n",
            "Dns query:\n",
            "RuleName: -\n",
            "UtcTime: 2024-07-28 19:05:11.949\n",
            "ProcessGuid: {18e8265a-9666-66a6-4f0b-000000004400}\n",
            "ProcessId: 3232\n",
            "QueryName: messaging\n",
            "QueryStatus: 0\n",
            "QueryResults: type:  5 prod-campaignaggregator.omexexternallfb.office.net.akadns.net;::ffff:52.109.16.3;\n",
            "Image: C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "from tokenizers import Tokenizer\n",
        "import torch\n",
        "import numpy as np\n",
        "import polars as pl\n",
        "\n",
        "# Load the custom tokenizer\n",
        "tokenizer = Tokenizer.from_file(\"log_tokenizer.json\")\n",
        "\n",
        "# Define the device (assuming you're using PyTorch and want to specify CPU or GPU)\n",
        "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
        "\n",
        "def vectorize_text(text):\n",
        "    MAX_LENGTH = 700  # Define the maximum length of tokens for the model\n",
        "\n",
        "    # Tokenize using the custom tokenizer\n",
        "    encoded = tokenizer.encode(text)\n",
        "\n",
        "    # Get token IDs\n",
        "    input_ids = encoded.ids\n",
        "\n",
        "    # Ensure the input_ids length is exactly MAX_LENGTH\n",
        "    input_ids = input_ids[:MAX_LENGTH] if len(input_ids) > MAX_LENGTH else input_ids + [0] * (MAX_LENGTH - len(input_ids))\n",
        "\n",
        "    # Convert to PyTorch tensor and move to the appropriate device\n",
        "    input_ids = torch.tensor([input_ids], dtype=torch.long).to(device)\n",
        "\n",
        "    # Get the model outputs, ensuring the input tensor is the correct size\n",
        "    outputs = linformer_model(input_ids)  # Now passing the tensor directly\n",
        "\n",
        "    # Assuming outputs is the tensor of interest\n",
        "    vector = outputs.mean(dim=1).detach()  # Detach the tensor from the GPU\n",
        "    return vector.cpu().numpy()  # Move tensor back to CPU and convert to numpy\n",
        "\n"
      ],
      "metadata": {
        "id": "EyvdFj83SQKI"
      },
      "execution_count": 127,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Assuming df_f is a Polars DataFrame with a column \"filtered_message\"\n",
        "df_f = df_f.with_columns(\n",
        "    pl.col(\"filtered_message\").map_elements(lambda x: vectorize_text(x).flatten(), return_dtype=pl.Object).alias(\"message_vector\")\n",
        ")"
      ],
      "metadata": {
        "id": "doS16Nq4S37g"
      },
      "execution_count": 15,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# broken\n",
        "\n",
        "\n",
        "import polars as pl\n",
        "import numpy as np\n",
        "import json\n",
        "\n",
        "# Function to convert vector to string\n",
        "def vector_to_string(vec):\n",
        "    return json.dumps(vec.tolist())\n",
        "\n",
        "# Function to convert string back to vector\n",
        "def string_to_vector(s):\n",
        "    return np.array(json.loads(s))\n",
        "\n",
        "# Convert vector column to string representation\n",
        "df_f = df_f.with_columns(\n",
        "    pl.col(\"message_vector\").map_elements(vector_to_string).alias(\"message_vector_str\")\n",
        ")\n",
        "\n",
        "# Drop the original vector column\n",
        "df_f = df_f.drop(\"message_vector\")\n",
        "\n",
        "# Write to Parquet\n",
        "df_f.write_parquet(\"lab_logs_blindtest_activity_sysmon_1000samples_july_28_2024_filtered_with_vectors.parquet\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "clEaIJjHXRhM",
        "outputId": "35b77b4d-5c35-46af-a0ae-645bd3f47328"
      },
      "execution_count": 39,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "shape: (5, 1)\n",
            "┌────────────────┐\n",
            "│ message_vector │\n",
            "│ ---            │\n",
            "│ u32            │\n",
            "╞════════════════╡\n",
            "│ 30000          │\n",
            "│ 30000          │\n",
            "│ 30000          │\n",
            "│ 30000          │\n",
            "│ 30000          │\n",
            "└────────────────┘\n",
            "Sample vector length: 30000\n",
            "Numpy vector shape: (30000,)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# broken\n",
        "\n",
        "import pandas as pd\n",
        "import numpy as np\n",
        "\n",
        "# Read from Parquet using pandas\n",
        "pdf_read = pd.read_parquet(\"lab_logs_blindtest_activity_sysmon_1000samples_july_28_2024_filtered_with_vectors.parquet\")\n",
        "\n",
        "# Convert lists back to numpy arrays if needed\n",
        "pdf_read['message_vector'] = pdf_read['message_vector_str'].apply(np.array)\n",
        "\n",
        "# Verify the shape of the vector\n",
        "print(pdf_read['message_vector'].str.len().head())\n",
        "\n",
        "# Check a sample vector to ensure dimensionality is preserved\n",
        "sample_vector = pdf_read['message_vector'].iloc[0]\n",
        "print(f\"Sample vector shape: {sample_vector.shape}\")\n",
        "\n",
        "# If you need to convert back to Polars\n",
        "df_read = pl.from_pandas(pdf_read)\n",
        "\n",
        "# Verify in Polars\n",
        "print(df_read.select(pl.col(\"message_vector\").list.len()).head())"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 327
        },
        "id": "981FBJ_rdh-V",
        "outputId": "f363fc9e-071a-44ca-c9b5-1a1ce009e23a"
      },
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "0    636264\n",
            "1    636780\n",
            "2    640357\n",
            "3    640529\n",
            "4    640428\n",
            "Name: message_vector, dtype: int64\n"
          ]
        },
        {
          "output_type": "error",
          "ename": "AttributeError",
          "evalue": "'str' object has no attribute 'shape'",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-4-30a279fdc346>\u001b[0m in \u001b[0;36m<cell line: 15>\u001b[0;34m()\u001b[0m\n\u001b[1;32m     13\u001b[0m \u001b[0;31m# Check a sample vector to ensure dimensionality is preserved\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     14\u001b[0m \u001b[0msample_vector\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpdf_read\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'message_vector'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0miloc\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 15\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"Sample vector shape: {sample_vector.shape}\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     16\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     17\u001b[0m \u001b[0;31m# If you need to convert back to Polars\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mAttributeError\u001b[0m: 'str' object has no attribute 'shape'"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import polars as pl\n",
        "import numpy as np\n",
        "\n",
        "print(df_f)\n",
        "\n",
        "print()\n",
        "# Convert the 'message_vector' column to a NumPy array\n",
        "X = np.array(df_f['message_vector'].to_list())\n",
        "print(\"Original data shape:\", X.shape)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "W849gxLgM3vP",
        "outputId": "368b0055-d479-405f-b9bd-388f4348a7ef"
      },
      "execution_count": 19,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "shape: (13_455, 16)\n",
            "┌────────────┬────────────┬────────────┬────────────┬───┬───────────┬──────────┬───────┬───────────┐\n",
            "│ @timestamp ┆ host.hostn ┆ host.ip    ┆ log.level  ┆ … ┆ temp_fold ┆ filename ┆ label ┆ message_v │\n",
            "│ ---        ┆ ame        ┆ ---        ┆ ---        ┆   ┆ er        ┆ ---      ┆ ---   ┆ ector     │\n",
            "│ datetime[μ ┆ ---        ┆ str        ┆ str        ┆   ┆ ---       ┆ str      ┆ str   ┆ ---       │\n",
            "│ s, UTC]    ┆ str        ┆            ┆            ┆   ┆ str       ┆          ┆       ┆ object    │\n",
            "╞════════════╪════════════╪════════════╪════════════╪═══╪═══════════╪══════════╪═══════╪═══════════╡\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informatio ┆ … ┆ No        ┆          ┆ good  ┆ [-0.48557 │\n",
            "│ 15:08:24.2 ┆            ┆ :35de:6006 ┆ n          ┆   ┆           ┆          ┆       ┆ 746  0.19 │\n",
            "│ 77 UTC     ┆            ┆ :d4cf      ┆            ┆   ┆           ┆          ┆       ┆ 012241    │\n",
            "│            ┆            ┆            ┆            ┆   ┆           ┆          ┆       ┆ 0.0323…   │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informatio ┆ … ┆ No        ┆          ┆ good  ┆ [-0.44357 │\n",
            "│ 15:08:24.4 ┆            ┆ :35de:6006 ┆ n          ┆   ┆           ┆          ┆       ┆ 03   0.22 │\n",
            "│ 88 UTC     ┆            ┆ :d4cf      ┆            ┆   ┆           ┆          ┆       ┆ 111408    │\n",
            "│            ┆            ┆            ┆            ┆   ┆           ┆          ┆       ┆ 0.0301…   │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informatio ┆ … ┆ No        ┆          ┆ good  ┆ [-0.29139 │\n",
            "│ 15:08:25.0 ┆            ┆ :35de:6006 ┆ n          ┆   ┆           ┆          ┆       ┆ 94   0.17 │\n",
            "│ 05 UTC     ┆            ┆ :d4cf      ┆            ┆   ┆           ┆          ┆       ┆ 932689    │\n",
            "│            ┆            ┆            ┆            ┆   ┆           ┆          ┆       ┆ 0.1016…   │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informatio ┆ … ┆ No        ┆          ┆ good  ┆ [-0.29095 │\n",
            "│ 15:08:25.0 ┆            ┆ :35de:6006 ┆ n          ┆   ┆           ┆          ┆       ┆ 116  0.16 │\n",
            "│ 05 UTC     ┆            ┆ :d4cf      ┆            ┆   ┆           ┆          ┆       ┆ 983014    │\n",
            "│            ┆            ┆            ┆            ┆   ┆           ┆          ┆       ┆ 0.1212…   │\n",
            "│ …          ┆ …          ┆ …          ┆ …          ┆ … ┆ …         ┆ …        ┆ …     ┆ …         │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informatio ┆ … ┆ No        ┆          ┆ good  ┆ [-0.27548 │\n",
            "│ 23:35:53.0 ┆            ┆ :35de:6006 ┆ n          ┆   ┆           ┆          ┆       ┆ 81   0.19 │\n",
            "│ 54 UTC     ┆            ┆ :d4cf      ┆            ┆   ┆           ┆          ┆       ┆ 213162    │\n",
            "│            ┆            ┆            ┆            ┆   ┆           ┆          ┆       ┆ 0.1174…   │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informatio ┆ … ┆ No        ┆          ┆ good  ┆ [-0.29359 │\n",
            "│ 23:35:54.1 ┆            ┆ :35de:6006 ┆ n          ┆   ┆           ┆          ┆       ┆ 23   0.18 │\n",
            "│ 33 UTC     ┆            ┆ :d4cf      ┆            ┆   ┆           ┆          ┆       ┆ 748309    │\n",
            "│            ┆            ┆            ┆            ┆   ┆           ┆          ┆       ┆ 0.1262…   │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informatio ┆ … ┆ No        ┆          ┆ good  ┆ [-0.27579 │\n",
            "│ 23:35:54.1 ┆            ┆ :35de:6006 ┆ n          ┆   ┆           ┆          ┆       ┆ 793  0.18 │\n",
            "│ 33 UTC     ┆            ┆ :d4cf      ┆            ┆   ┆           ┆          ┆       ┆ 788172    │\n",
            "│            ┆            ┆            ┆            ┆   ┆           ┆          ┆       ┆ 0.1131…   │\n",
            "│ 2024-07-28 ┆ win10      ┆ fe80::c1af ┆ informatio ┆ … ┆ No        ┆          ┆ good  ┆ [-0.35910 │\n",
            "│ 23:41:55.3 ┆            ┆ :35de:6006 ┆ n          ┆   ┆           ┆          ┆       ┆ 064       │\n",
            "│ 01 UTC     ┆            ┆ :d4cf      ┆            ┆   ┆           ┆          ┆       ┆ 0.1997092 │\n",
            "│            ┆            ┆            ┆            ┆   ┆           ┆          ┆       ┆ 0.0654…   │\n",
            "└────────────┴────────────┴────────────┴────────────┴───┴───────────┴──────────┴───────┴───────────┘\n",
            "\n",
            "Original data shape: (13455, 30000)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Read vectors into DataFrame"
      ],
      "metadata": {
        "id": "oyMG2LKK4LqU"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "# AutoML with TPOT (Supervised Learning)"
      ],
      "metadata": {
        "id": "ZqGIRBU6aE3U"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import polars as pl\n",
        "import pandas as pd\n",
        "\n",
        "# Assuming df_f is your Polars DataFrame\n",
        "try:\n",
        "    # Extract data from Polars DataFrame columns\n",
        "    data = {col: df_f[col].to_list() for col in df_f.columns}\n",
        "    # Create a Pandas DataFrame from the extracted data\n",
        "    df = pd.DataFrame(data)\n",
        "except Exception as e:\n",
        "    print(f\"An error occurred: {e}\")\n",
        "\n",
        "# Display the Pandas DataFrame info and dtypes\n",
        "if 'df' in locals():\n",
        "    print(\"Pandas DataFrame:\")\n",
        "    print(df.info())\n",
        "    print(df.dtypes)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "9JjYJzacaD-T",
        "outputId": "a80aa8c4-1624-438b-9407-135cf4f3c284"
      },
      "execution_count": 28,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Pandas DataFrame:\n",
            "<class 'pandas.core.frame.DataFrame'>\n",
            "RangeIndex: 13455 entries, 0 to 13454\n",
            "Data columns (total 16 columns):\n",
            " #   Column            Non-Null Count  Dtype              \n",
            "---  ------            --------------  -----              \n",
            " 0   @timestamp        13455 non-null  datetime64[ns, UTC]\n",
            " 1   host.hostname     13455 non-null  object             \n",
            " 2   host.ip           13455 non-null  object             \n",
            " 3   log.level         13455 non-null  object             \n",
            " 4   winlog.event_id   13455 non-null  int64              \n",
            " 5   winlog.task       13455 non-null  object             \n",
            " 6   message           13455 non-null  object             \n",
            " 7   filtered_message  13455 non-null  object             \n",
            " 8   image             13455 non-null  object             \n",
            " 9   target_filename   13455 non-null  object             \n",
            " 10  parent_image      13455 non-null  object             \n",
            " 11  text              13455 non-null  object             \n",
            " 12  temp_folder       13455 non-null  object             \n",
            " 13  filename          13455 non-null  object             \n",
            " 14  label             13455 non-null  object             \n",
            " 15  message_vector    13455 non-null  object             \n",
            "dtypes: datetime64[ns, UTC](1), int64(1), object(14)\n",
            "memory usage: 1.6+ MB\n",
            "None\n",
            "@timestamp          datetime64[ns, UTC]\n",
            "host.hostname                    object\n",
            "host.ip                          object\n",
            "log.level                        object\n",
            "winlog.event_id                   int64\n",
            "winlog.task                      object\n",
            "message                          object\n",
            "filtered_message                 object\n",
            "image                            object\n",
            "target_filename                  object\n",
            "parent_image                     object\n",
            "text                             object\n",
            "temp_folder                      object\n",
            "filename                         object\n",
            "label                            object\n",
            "message_vector                   object\n",
            "dtype: object\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "X = np.array(df['message_vector'].tolist())\n",
        "print(X.shape)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "5NHDYuDAiUis",
        "outputId": "2a639822-3cba-4e68-9124-9ec8af95c818"
      },
      "execution_count": 30,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "(13455, 30000)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## TPOT for Supervised Learning with Algo stats"
      ],
      "metadata": {
        "id": "Gf4Fu4cDs4pr"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.preprocessing import LabelEncoder\n",
        "from tpot import TPOTClassifier\n",
        "from sklearn.metrics import recall_score\n",
        "import numpy as np\n",
        "import pandas as pd\n",
        "from collections import defaultdict\n",
        "import time\n",
        "import re\n",
        "from tabulate import tabulate\n",
        "\n",
        "# Assuming df is already loaded and contains 'message_vector' and 'label' columns\n",
        "\n",
        "# Encode labels\n",
        "le = LabelEncoder()\n",
        "df['label_encoded'] = le.fit_transform(df['label'])\n",
        "\n",
        "# Split data\n",
        "X = np.array(df['message_vector'].tolist())\n",
        "y = df['label_encoded'].values\n",
        "\n",
        "# Initialize results storage\n",
        "results = defaultdict(list)\n",
        "\n",
        "# Number of runs\n",
        "n_runs = 10\n",
        "\n",
        "# Function to extract number of features selected\n",
        "def get_n_features(pipeline_str):\n",
        "    match = re.search(r'SelectPercentile\\(score_func=f_classif, percentile=(\\d+)\\)', pipeline_str)\n",
        "    if match:\n",
        "        percentile = int(match.group(1))\n",
        "        return int(X.shape[1] * percentile / 100)\n",
        "    return X.shape[1]  # If no feature selection, return all features\n",
        "\n",
        "# Initialize best_tpot and best_recall\n",
        "best_tpot = None\n",
        "best_recall = 0\n",
        "\n",
        "for run in range(n_runs):\n",
        "    print(f\"\\nStarting run {run + 1}/{n_runs}\")\n",
        "    start_time = time.time()\n",
        "\n",
        "    # Split data for this run\n",
        "    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42 + run)\n",
        "\n",
        "    # TPOT classifier with recall as the metric\n",
        "    tpot = TPOTClassifier(\n",
        "        scoring='recall',  # Use recall for single-label classification\n",
        "        verbosity=2,\n",
        "        generations=5,\n",
        "        population_size=20,\n",
        "        random_state=42 + run\n",
        "    )\n",
        "\n",
        "    # Fit\n",
        "    tpot.fit(X_train, y_train)\n",
        "\n",
        "    # Predict and calculate recall score\n",
        "    y_pred = tpot.predict(X_test)\n",
        "    recall = recall_score(y_test, y_pred, average='macro')  # 'macro' for single-label multi-class\n",
        "\n",
        "    # Update best_tpot if this run has better recall score\n",
        "    if recall > best_recall:\n",
        "        best_recall = recall\n",
        "        best_tpot = tpot\n",
        "\n",
        "    # Get pipeline string and extract number of features\n",
        "    pipeline_str = str(tpot.fitted_pipeline_)\n",
        "    n_features = get_n_features(pipeline_str)\n",
        "\n",
        "    # Store results\n",
        "    results['run'].append(run + 1)\n",
        "    results['recall_score'].append(recall)\n",
        "    results['best_pipeline'].append(pipeline_str)\n",
        "    results['n_features'].append(n_features)\n",
        "    results['runtime'].append(time.time() - start_time)\n",
        "    results['pipelines_tested'].append(tpot.evaluated_individuals_)\n",
        "\n",
        "    print(f\"Run {run + 1} completed. Recall Score: {recall:.4f}, Features selected: {n_features}, Pipelines tested: {len(tpot.evaluated_individuals_)}\")\n",
        "\n",
        "# Convert results to DataFrame\n",
        "results_df = pd.DataFrame(results)\n",
        "\n",
        "# Print summary statistics\n",
        "print(\"\\nSummary Statistics:\")\n",
        "print(results_df.describe())\n",
        "\n",
        "# Save results to CSV\n",
        "results_df.to_csv('tpot_recall_results.csv', index=False)\n",
        "\n",
        "print(\"\\nResults saved to 'tpot_recall_results.csv'\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000,
          "referenced_widgets": [
            "a336f820e5124f5d9e344bb8b0d12ee5",
            "150475d8c96148eaa9d5230b85283e64",
            "19f3e10b3dd94c71b9add7ee1d8f4c13",
            "5aa33fe21abc482c997975ec5712d0da",
            "0b51be1ad43c43fa89041fea2b062768",
            "5ab992330571497ab2a07cd04841b9d3",
            "4a8897c90c19427fa82afa4fa62f31da",
            "7df01173ffee4067b1c7490fab0b571b",
            "6bd42f421a4e4e60b2d7edc8784e07aa",
            "09932ad0a1fe4fd196b38b16dc74f94a",
            "f7354d5ee6e04705968e30d7a43ebbe7",
            "feb69d6d248b4e2abf52d6622dd3638b",
            "712ff38a74994c5082fe487de437ec67",
            "81a29faa64d44f2c9a173a9213618f4c",
            "35012b6363cf4ca88c4c5221d264ec25",
            "598537621c514f51be27ebaf9bde7d54",
            "825b3f67b44b4136a36909da95412031",
            "8b121673d208412ab1f426a3ff1698ba",
            "02a6753498b14c459016b7ff31c4b6d7",
            "384c150f10e94ba78243d1a260e66887",
            "bb1d1e093dec47f393c713548bfc6cc6",
            "05b2a6fb28aa434a94c18c7d64cd55f1",
            "a2f43127d721436185ba241b84cc87d7",
            "3618c2d6264c4359a17bbdecc7db70d8",
            "286cc95f7d6c47a6863c7fda02f83d3f",
            "cabaca33a5cc4d0fb9fa99f42ece4167",
            "153d243e01b24b5cad305ec4d886b922",
            "e8bf60db6d1b47b2a6752fcceebad0e7",
            "600f0f18ccaf4c89aa37feaa0b360f13",
            "33f5284de07e4be29e4f39d5aaaa2d9b",
            "4a850f0d51014dfa9b55c86d04707b24",
            "ae8a589b32c44836894c6d3b708b896d",
            "a57766432bb54d24a3869e0553c026d1",
            "2cf8dcb41b3340cea65c251b3d8681d4",
            "6e3a5bb9d6d7456982660f0edcc3b8c0",
            "0bb2408ba21a481983c0a74f1411ef0a",
            "4528e59b16d04228a5cc508fadb56a54",
            "61072176986f4c9fb48f403c25ac3024",
            "9881b9f569b3445897972c0340870318",
            "f09971fa706c4509b3530edabeb47864",
            "7510b9c108494e3dbe5ee031bf367e2b",
            "2ed7ace57f89415fba714200fe44c2f9",
            "bb51c5c7834c419a87a30752cd769d91",
            "cc9bf86d64fc48f490a38fae5483ddb2",
            "ed38c4b5280a4e0da6b3e979ca380db5",
            "045cf04f33a643e8816a674d659cc252",
            "c5b0b6bebd0b49e0b10116770251023e",
            "c42b63c849f7469496fa292cc53efae3",
            "a336fafd8e334185a39ca81268ca9f90",
            "007b3fd39d1c480c959db4ed7abb37fe",
            "5247fe5ea6724b15934a7142b8a8a8b1",
            "ff008c746112461781825f85f212dd81",
            "c290371939ed4a8999c1411b426448ed",
            "09e3fa8828024d1cab95af2452cbf516",
            "b1f5ea5f99b249dc9c8d2b26f43485f0",
            "b41836beb11a4623b7fa6091494c0e85",
            "d1fb8e94033f47d3b7123c513473519d",
            "0f90f79a7f0d4bcbaa2ada2379b65f53",
            "dedf553fc5c24b14a86a779a61a39be5",
            "6566843282bc4bb59c7044ab3b812f40",
            "fcefb4debd9a4445a94a9fc5847662e4",
            "bbe6750092e44b2aafc5afb33e71ae88",
            "50769ac7392e4bccaf83e32f8e5e3754",
            "f202232d07f946ccaf899e672c2b7dd7",
            "111571775b67440db61746dc6a653380",
            "1fc51b4708134f18995b5dd73631446d",
            "f466f42deeac4321b8b9768a11d6a755",
            "06b74e83419b4d2b94913aeb490a7cb0",
            "de16524e0e5d46f9a8b511fa82e748a8",
            "e13204ee59ab400280347f23c0d31705",
            "ad599c9ce9b04059b37c94dcae4b23a8",
            "aeefdbc3453543baa3d6e72ccd15ee54",
            "3a84a44443a944c399486902d4db6bdc",
            "2e55913ae8944ef9923724a8351bacb4",
            "dcc3e817b40643388a5f99a54fe13e43",
            "272dc71a7ccf4608bfdea6a17524a886",
            "5a3d943f85e34887aeb64a0e6b189f32",
            "065f516618c041f1ba57df39d17cc95d",
            "ca2767bb06444f03a1a31dd9e5216c45",
            "1d9710db98c04adeb3855f4062301e24",
            "57141f99793f45708db3961cf4178fc9",
            "6c4c02ca0cb64050ac7e201a1a60be72",
            "b6b5382bb2684e74a2c36b49f423eee3",
            "a4a4a02a4332458789866a0e0e7839d3",
            "871438bb5a0d4d31b3b8a0f18fcdac78",
            "294ffc18963140ea96c01095e3a1300f",
            "6dda83426ca749bd822d2bd0d39744ed",
            "d37293f1d67f45babbe2a875df701c40",
            "2ae5d11987c44076b95c1294af800c28",
            "75c27d61248b477e9c58211b066ab62f",
            "00628b308f4244c4ad533a67cb90ba43",
            "851e8257d678458db2612a04803e8c17",
            "8f472688c98745f28345f31e852b361b",
            "f1b8071a183e47af81e8d96290ca7370",
            "18d1acb1cdad46f1832c98ab44f0bc53",
            "21abac8483874bb1acdc45f6e8f78b53",
            "b4e4db272e35407899de20c7b30d1551",
            "9d4143827e3f4e949cde68384a7beb59",
            "aa805872f24140f6aa6ee2ac72b34b59",
            "ed028f92fe6544159b14dcf220623223",
            "2ff14125384a4f3cad97a03f9d2ff55f",
            "d70eced834c64f399a3db48dcc19f802",
            "b85cfd236fbc4c50b2572f0ff7ddea1c",
            "b4e51caccd1e40baac5143667206d8cb",
            "8031586f1f8d4dbbaf44708b12f4eb13",
            "a2278a2947354727a76758cb4bf5e682",
            "a2debbdff91649f29c7a579911090df4",
            "7d4b85786ff04c9d843753c91c80f854",
            "cb681559245a4d12bd4551bcfea063c4",
            "0967c0fe1d9a4048b4e7b4266a75d893"
          ]
        },
        "id": "usxaQgkSbEND",
        "outputId": "7ace5c69-7761-48c4-ab9f-ff2623cf9355"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Starting run 1/10\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/120 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "a336f820e5124f5d9e344bb8b0d12ee5"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 2 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 3 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 4 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 5 - Current best internal CV score: 1.0\n",
            "\n",
            "Best pipeline: XGBClassifier(input_matrix, learning_rate=0.001, max_depth=9, min_child_weight=7, n_estimators=100, n_jobs=1, subsample=0.45, verbosity=0)\n",
            "Run 1 completed. Recall Score: 0.5000, Features selected: 6, Pipelines tested: 117\n",
            "\n",
            "Starting run 2/10\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/120 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "feb69d6d248b4e2abf52d6622dd3638b"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 2 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 3 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 4 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 5 - Current best internal CV score: 1.0\n",
            "\n",
            "Best pipeline: ExtraTreesClassifier(input_matrix, bootstrap=False, criterion=entropy, max_features=0.8500000000000001, min_samples_leaf=20, min_samples_split=19, n_estimators=100)\n",
            "Run 2 completed. Recall Score: 0.5000, Features selected: 6, Pipelines tested: 116\n",
            "\n",
            "Starting run 3/10\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/120 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "a2f43127d721436185ba241b84cc87d7"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 2 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 3 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 4 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 5 - Current best internal CV score: 1.0\n",
            "\n",
            "Best pipeline: LogisticRegression(input_matrix, C=0.001, dual=False, penalty=l2)\n",
            "Run 3 completed. Recall Score: 0.5000, Features selected: 6, Pipelines tested: 119\n",
            "\n",
            "Starting run 4/10\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/120 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "2cf8dcb41b3340cea65c251b3d8681d4"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 2 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 3 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 4 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 5 - Current best internal CV score: 1.0\n",
            "\n",
            "Best pipeline: RandomForestClassifier(input_matrix, bootstrap=True, criterion=gini, max_features=0.6500000000000001, min_samples_leaf=18, min_samples_split=8, n_estimators=100)\n",
            "Run 4 completed. Recall Score: 0.5000, Features selected: 6, Pipelines tested: 113\n",
            "\n",
            "Starting run 5/10\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/120 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "ed38c4b5280a4e0da6b3e979ca380db5"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 2 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 3 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 4 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 5 - Current best internal CV score: 1.0\n",
            "\n",
            "Best pipeline: MLPClassifier(input_matrix, alpha=0.01, learning_rate_init=0.001)\n",
            "Run 5 completed. Recall Score: 0.5000, Features selected: 6, Pipelines tested: 117\n",
            "\n",
            "Starting run 6/10\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/120 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "b41836beb11a4623b7fa6091494c0e85"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 2 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 3 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 4 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 5 - Current best internal CV score: 1.0\n",
            "\n",
            "Best pipeline: XGBClassifier(input_matrix, learning_rate=0.001, max_depth=1, min_child_weight=5, n_estimators=100, n_jobs=1, subsample=0.7000000000000001, verbosity=0)\n",
            "Run 6 completed. Recall Score: 0.5000, Features selected: 6, Pipelines tested: 117\n",
            "\n",
            "Starting run 7/10\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/120 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "f466f42deeac4321b8b9768a11d6a755"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 2 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 3 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 4 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 5 - Current best internal CV score: 1.0\n",
            "\n",
            "Best pipeline: ExtraTreesClassifier(input_matrix, bootstrap=True, criterion=gini, max_features=0.15000000000000002, min_samples_leaf=17, min_samples_split=14, n_estimators=100)\n",
            "Run 7 completed. Recall Score: 0.5000, Features selected: 6, Pipelines tested: 119\n",
            "\n",
            "Starting run 8/10\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/120 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "065f516618c041f1ba57df39d17cc95d"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 2 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 3 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 4 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 5 - Current best internal CV score: 1.0\n",
            "\n",
            "Best pipeline: KNeighborsClassifier(input_matrix, n_neighbors=55, p=1, weights=uniform)\n",
            "Run 8 completed. Recall Score: 0.5000, Features selected: 6, Pipelines tested: 116\n",
            "\n",
            "Starting run 9/10\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/120 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "2ae5d11987c44076b95c1294af800c28"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 2 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 3 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 4 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 5 - Current best internal CV score: 1.0\n",
            "\n",
            "Best pipeline: ExtraTreesClassifier(input_matrix, bootstrap=False, criterion=entropy, max_features=0.1, min_samples_leaf=5, min_samples_split=8, n_estimators=100)\n",
            "Run 9 completed. Recall Score: 0.5000, Features selected: 6, Pipelines tested: 116\n",
            "\n",
            "Starting run 10/10\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/120 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "ed028f92fe6544159b14dcf220623223"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 2 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 3 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 4 - Current best internal CV score: 1.0\n",
            "\n",
            "Generation 5 - Current best internal CV score: 1.0\n",
            "\n",
            "Best pipeline: MLPClassifier(input_matrix, alpha=0.001, learning_rate_init=0.001)\n",
            "Run 10 completed. Recall Score: 0.5000, Features selected: 6, Pipelines tested: 113\n",
            "\n",
            "Summary Statistics:\n",
            "            run  recall_score  n_features     runtime\n",
            "count  10.00000          10.0        10.0   10.000000\n",
            "mean    5.50000           0.5         6.0  334.156930\n",
            "std     3.02765           0.0         0.0  127.160364\n",
            "min     1.00000           0.5         6.0  114.973269\n",
            "25%     3.25000           0.5         6.0  262.173025\n",
            "50%     5.50000           0.5         6.0  328.878905\n",
            "75%     7.75000           0.5         6.0  377.474684\n",
            "max    10.00000           0.5         6.0  595.090283\n",
            "\n",
            "Results saved to 'tpot_recall_results.csv'\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### TPOT Algo Stats: Supervised Learning"
      ],
      "metadata": {
        "id": "KYJ1AkAStACV"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Convert results to DataFrame\n",
        "results_df = pd.DataFrame(results)\n",
        "\n",
        "# Print summary statistics\n",
        "print(\"\\nSummary Statistics:\")\n",
        "print(results_df.describe())\n",
        "\n",
        "# Save results to CSV\n",
        "results_df.to_csv('tpot_results_recall_features_pipelines.csv', index=False)\n",
        "\n",
        "print(\"\\nResults saved to 'tpot_results_recall_features_pipelines.csv'\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "ZAFOj5Ya7GhW",
        "outputId": "cb1e3293-32d8-4688-baae-3766fdc0a997"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Summary Statistics:\n",
            "            run  recall_score  n_features     runtime\n",
            "count  10.00000          10.0        10.0   10.000000\n",
            "mean    5.50000           0.5         6.0  334.156930\n",
            "std     3.02765           0.0         0.0  127.160364\n",
            "min     1.00000           0.5         6.0  114.973269\n",
            "25%     3.25000           0.5         6.0  262.173025\n",
            "50%     5.50000           0.5         6.0  328.878905\n",
            "75%     7.75000           0.5         6.0  377.474684\n",
            "max    10.00000           0.5         6.0  595.090283\n",
            "\n",
            "Results saved to 'tpot_results_recall_features_pipelines.csv'\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Model export: TPOT's best pipeline, Supervised"
      ],
      "metadata": {
        "id": "vM6TVwHYtKNa"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import dill\n",
        "\n",
        "# Assuming `best_tpot` is your optimized TPOT object\n",
        "if best_tpot is not None:\n",
        "    with open('best_tpot_model.pkl', 'wb') as f:\n",
        "        dill.dump(best_tpot.fitted_pipeline_, f)\n",
        "    print(\"TPOT model saved using dill.\")\n",
        "else:\n",
        "    print(\"No valid TPOT model was found.\")\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "ojygkYhE3B_j",
        "outputId": "dd75bc6d-2eb8-4e2f-9899-e58bf6333dcb"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "TPOT model saved using dill.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Evaluation of the model"
      ],
      "metadata": {
        "id": "lqXIlzZ0u7oN"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import matplotlib.pyplot as plt\n",
        "\n",
        "fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(10, 18))\n",
        "\n",
        "ax1.plot(results_df['run'], results_df['recall_score'], 'bo-')\n",
        "ax1.set_title('TPOT Performance (Recall Score) Across Runs')\n",
        "ax1.set_xlabel('Run')\n",
        "ax1.set_ylabel('Recall Score')\n",
        "ax1.grid(True)\n",
        "\n",
        "ax2.plot(results_df['run'], results_df['n_features'], 'ro-')\n",
        "ax2.set_title('Number of Features Selected Across Runs')\n",
        "ax2.set_xlabel('Run')\n",
        "ax2.set_ylabel('Number of Features')\n",
        "ax2.grid(True)\n",
        "\n",
        "ax3.plot(results_df['run'], results_df['pipelines_tested'].apply(len), 'go-')\n",
        "ax3.set_title('Number of Pipelines Tested Across Runs')\n",
        "ax3.set_xlabel('Run')\n",
        "ax3.set_ylabel('Number of Pipelines')\n",
        "ax3.grid(True)\n",
        "\n",
        "plt.tight_layout()\n",
        "plt.savefig('tpot_performance_features_pipelines.png')\n",
        "plt.show()"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "PbOIGDR9cAgM",
        "outputId": "4fd4a052-789e-49db-aad8-f2f66524f254"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 1000x1800 with 3 Axes>"
            ],
            "image/png": "[encoded data, 117008 characters]\n"
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.metrics import confusion_matrix, classification_report\n",
        "\n",
        "# Assuming you have access to the best model and test data\n",
        "best_model = best_tpot.fitted_pipeline_\n",
        "y_pred = best_model.predict(X_test)\n",
        "\n",
        "# Print confusion matrix\n",
        "print(\"Confusion Matrix:\")\n",
        "print(confusion_matrix(y_test, y_pred))\n",
        "\n",
        "# Print classification report\n",
        "print(\"\\nClassification Report:\")\n",
        "print(classification_report(y_test, y_pred))\n",
        "\n",
        "# Check unique predictions\n",
        "unique_predictions = np.unique(y_pred)\n",
        "print(\"\\nUnique Predictions:\", unique_predictions)\n",
        "\n",
        "# Check class distribution in test set\n",
        "unique_classes, class_counts = np.unique(y_test, return_counts=True)\n",
        "print(\"\\nClass Distribution in Test Set:\")\n",
        "for cls, count in zip(unique_classes, class_counts):\n",
        "    print(f\"Class {cls}: {count}\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 218
        },
        "id": "8KwJfQvG0ZvJ",
        "outputId": "13426649-eaaf-4fc9-8392-f648a79da6fe"
      },
      "execution_count": 7,
      "outputs": [
        {
          "output_type": "error",
          "ename": "NameError",
          "evalue": "name 'best_tpot' is not defined",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-7-9a3faf7a46ad>\u001b[0m in \u001b[0;36m<cell line: 4>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0;31m# Assuming you have access to the best model and test data\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mbest_model\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbest_tpot\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfitted_pipeline_\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      5\u001b[0m \u001b[0my_pred\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbest_model\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX_test\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mNameError\u001b[0m: name 'best_tpot' is not defined"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Handling Imbalanced Data"
      ],
      "metadata": {
        "id": "RG5bRw2lt0GD"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from imblearn.over_sampling import SMOTE\n",
        "from imblearn.under_sampling import RandomUnderSampler\n",
        "from imblearn.pipeline import Pipeline\n",
        "from sklearn.metrics import balanced_accuracy_score, roc_auc_score, average_precision_score\n",
        "from sklearn.model_selection import cross_val_score\n",
        "from sklearn.ensemble import RandomForestClassifier\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.preprocessing import LabelEncoder\n",
        "from sklearn.pipeline import Pipeline\n",
        "from sklearn.feature_selection import RFECV\n",
        "from sklearn.preprocessing import QuantileTransformer\n",
        "from sklearn.decomposition import PCA\n",
        "from sklearn.ensemble import RandomForestClassifier\n",
        "from imblearn.over_sampling import SMOTE\n",
        "from imblearn.pipeline import Pipeline as ImbPipeline\n",
        "\n",
        "\n",
        "# Encode labels\n",
        "le = LabelEncoder()\n",
        "df['label_encoded'] = le.fit_transform(df['label'])\n",
        "\n",
        "# Split data\n",
        "X = np.array(df['message_vector'].tolist())\n",
        "y = df['label_encoded'].values\n",
        "\n",
        "# Split data for this run\n",
        "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
        "\n",
        "\n",
        "# Feature selection\n",
        "feature_selector = RFECV(\n",
        "    estimator=RandomForestClassifier(n_estimators=10, class_weight='balanced', random_state=42),\n",
        "    step=5000,\n",
        "    min_features_to_select=1000,\n",
        "    cv=3,\n",
        "    scoring='balanced_accuracy',\n",
        "    n_jobs=-1\n",
        ")\n",
        "\n",
        "\n",
        "# Quantile transformer\n",
        "quantile_transformer = QuantileTransformer(n_quantiles=1000, output_distribution='normal', random_state=42)\n",
        "\n",
        "# Dimensionality reduction\n",
        "pca = PCA(n_components=0.95)\n",
        "\n",
        "# Create the pipeline\n",
        "pipeline = ImbPipeline([\n",
        "    ('feature_selection', feature_selector),\n",
        "    ('quantile_transform', quantile_transformer),\n",
        "    ('pca', pca),\n",
        "    ('smote', SMOTE(random_state=42)),\n",
        "    ('classifier', RandomForestClassifier(class_weight='balanced', random_state=42))\n",
        "])\n",
        "\n",
        "# Fit the pipeline and make predictions\n",
        "pipeline.fit(X_train, y_train)\n",
        "y_pred = pipeline.predict(X_test)\n",
        "\n",
        "# Calculate metrics\n",
        "balanced_acc = balanced_accuracy_score(y_test, y_pred)\n",
        "roc_auc = roc_auc_score(y_test, pipeline.predict_proba(X_test)[:, 1])\n",
        "avg_precision = average_precision_score(y_test, pipeline.predict_proba(X_test)[:, 1])\n",
        "\n",
        "print(f\"Balanced Accuracy: {balanced_acc:.4f}\")\n",
        "print(f\"ROC AUC: {roc_auc:.4f}\")\n",
        "print(f\"Average Precision: {avg_precision:.4f}\")\n",
        "\n",
        "# Cross-validation\n",
        "cv_scores = cross_val_score(pipeline, X, y, cv=5, scoring='balanced_accuracy')\n",
        "print(f\"Cross-validation Balanced Accuracy: {cv_scores.mean():.4f} (+/- {cv_scores.std() * 2:.4f})\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "zh-ULZZ0099E",
        "outputId": "9bb9313a-7e4c-40bd-8c64-f78d1c57636d"
      },
      "execution_count": 34,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Balanced Accuracy: 0.6000\n",
            "ROC AUC: 0.9933\n",
            "Average Precision: 0.9999\n",
            "Cross-validation Balanced Accuracy: 0.7230 (+/- 0.1013)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Fit the feature selector and print the number of selected features\n",
        "feature_selector.fit(X_train, y_train)\n",
        "print(f\"Number of features selected: {feature_selector.n_features_}\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "brczGHV083MW",
        "outputId": "54081516-0074-47d2-da92-ad921d8500f8"
      },
      "execution_count": 60,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Number of features selected: 25000\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Testing the predictions"
      ],
      "metadata": {
        "id": "zCJ3jHyZQIS_"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "test_message_benign = random_good_message\n",
        "test_message_bad = random_bad_message\n",
        "\n",
        "\n",
        "from tokenizers import Tokenizer\n",
        "import torch\n",
        "import numpy as np\n",
        "import polars as pl\n",
        "import numpy as np\n",
        "\n",
        "# Load the custom tokenizer\n",
        "tokenizer = Tokenizer.from_file(\"log_tokenizer.json\")\n",
        "\n",
        "# Define the device (assuming you're using PyTorch and want to specify CPU or GPU)\n",
        "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
        "\n",
        "vector_good = vectorize_text(test_message_benign).flatten()\n",
        "print(len(vector_good))\n",
        "\n",
        "\n",
        "# Assuming 'vector' is your input\n",
        "vector_good = np.array(vector_good)\n",
        "vector_2d_good = vector_good.reshape(1, -1)\n",
        "\n",
        "# Class prediction\n",
        "prediction = pipeline.predict(vector_2d_good)\n",
        "print(\"Predicted class:\", prediction[0])\n",
        "\n",
        "# Probability prediction\n",
        "probabilities = pipeline.predict_proba(vector_2d_good)\n",
        "print(\"Class probabilities:\", probabilities[0])\n",
        "\n",
        "\n",
        "vector_bad = vectorize_text(test_message_bad).flatten()\n",
        "print(len(vector_bad))\n",
        "\n",
        "# Assuming 'vector' is your input\n",
        "vector_bad = np.array(vector_bad)\n",
        "vector_2d_bad = vector_bad.reshape(1, -1)\n",
        "\n",
        "# Class prediction\n",
        "prediction = pipeline.predict(vector_2d_bad)\n",
        "print(\"Predicted class:\", prediction[0])\n",
        "\n",
        "# Probability prediction\n",
        "probabilities = pipeline.predict_proba(vector_2d_bad)\n",
        "print(\"Class probabilities:\", probabilities[0])\n",
        "\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "3HpxPWlIPHT4",
        "outputId": "4501c78a-74d8-49b7-bc3e-0c647ba5e71f"
      },
      "execution_count": 53,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "30000\n",
            "Predicted class: 1\n",
            "Class probabilities: [0. 1.]\n",
            "30000\n",
            "Predicted class: 0\n",
            "Class probabilities: [0.56 0.44]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Save the Supervised Learning Model (joblib)\n",
        "\n",
        "Generating the model can take roughly 1h of computation time on a modern 8 core / 64 GB RAM server."
      ],
      "metadata": {
        "id": "YVPPGLSA6uZ-"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import joblib\n",
        "import numpy as np\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.metrics import f1_score\n",
        "\n",
        "\n",
        "# Save the model using joblib\n",
        "model_filename = 'manual_model_123.joblib'\n",
        "joblib.dump(pipeline, model_filename)\n",
        "\n",
        "print(f\"\\nModel exported as joblib: {model_filename}\")\n",
        "\n",
        "\n",
        "# Verify the saved model\n",
        "try:\n",
        "    loaded_model = joblib.load(model_filename)\n",
        "except Exception as e:\n",
        "    print(f\"\\nError verifying saved model: {str(e)}\")\n",
        "\n",
        "# Print information about how to use the saved model\n",
        "print(\"\\nTo use the saved model in the future:\")\n",
        "print(\"1. Load the model: loaded_model = joblib.load('best_tpot_nn_model.joblib')\")\n",
        "print(\"2. Make predictions: predictions = loaded_model.predict(X)\")\n",
        "print(\"Note: Make sure to preprocess your input data (X) the same way as during training.\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "lpbrnU_06Gfi",
        "outputId": "007bae7d-2533-477b-b23f-8699f09321bb"
      },
      "execution_count": 36,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Model exported as joblib: manual_model_123.joblib\n",
            "\n",
            "To use the saved model in the future:\n",
            "1. Load the model: loaded_model = joblib.load('best_tpot_nn_model.joblib')\n",
            "2. Make predictions: predictions = loaded_model.predict(X)\n",
            "Note: Make sure to preprocess your input data (X) the same way as during training.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Confusion matrix"
      ],
      "metadata": {
        "id": "l1u70hEaAYgD"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay\n",
        "import matplotlib.pyplot as plt\n",
        "\n",
        "# Make predictions\n",
        "y_pred = pipeline.predict(X_test)\n",
        "\n",
        "# Create the confusion matrix\n",
        "cm = confusion_matrix(y_test, y_pred)\n",
        "\n",
        "# Create a ConfusionMatrixDisplay object\n",
        "disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=['good', 'bad'])\n",
        "\n",
        "# Plot the confusion matrix\n",
        "plt.figure(figsize=(10, 7))\n",
        "disp.plot(cmap='Blues', values_format='d')\n",
        "plt.title('Confusion Matrix')\n",
        "plt.show()\n",
        "\n",
        "# Print the confusion matrix\n",
        "print(\"Confusion Matrix:\")\n",
        "print(cm)\n",
        "\n",
        "# Calculate and print additional metrics\n",
        "tn, fp, fn, tp = cm.ravel()\n",
        "precision = tp / (tp + fp)\n",
        "recall = tp / (tp + fn)\n",
        "f1_score = 2 * (precision * recall) / (precision + recall)\n",
        "\n",
        "print(f\"\\nPrecision: {precision:.4f}\")\n",
        "print(f\"Recall: {recall:.4f}\")\n",
        "print(f\"F1-score: {f1_score:.4f}\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 617
        },
        "id": "5GaLAsg661Qh",
        "outputId": "a546f9f0-9c8f-433c-d5f5-8440a058f840"
      },
      "execution_count": 37,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 1000x700 with 0 Axes>"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 640x480 with 2 Axes>"
            ],
            "image/png": "[encoded data, 25844 characters]\n"
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Confusion Matrix:\n",
            "[[   5   20]\n",
            " [   0 2666]]\n",
            "\n",
            "Precision: 0.9926\n",
            "Recall: 1.0000\n",
            "F1-score: 0.9963\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## CV scores"
      ],
      "metadata": {
        "id": "0jtLBuvnAeND"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.model_selection import StratifiedKFold\n",
        "from sklearn.metrics import balanced_accuracy_score, roc_auc_score, average_precision_score\n",
        "import numpy as np\n",
        "\n",
        "# Define the number of folds\n",
        "n_splits = 5\n",
        "\n",
        "# Create a StratifiedKFold object\n",
        "skf = StratifiedKFold(n_splits=n_splits, shuffle=True, random_state=42)\n",
        "\n",
        "# Initialize lists to store the scores\n",
        "balanced_accuracy_scores = []\n",
        "roc_auc_scores = []\n",
        "average_precision_scores = []\n",
        "\n",
        "# Perform cross-validation manuall\n",
        "for fold, (train_index, val_index) in enumerate(skf.split(X, y), 1):\n",
        "    X_train, X_val = X[train_index], X[val_index]\n",
        "    y_train, y_val = y[train_index], y[val_index]\n",
        "\n",
        "    # Fit the pipeline\n",
        "    pipeline.fit(X_train, y_train)\n",
        "\n",
        "    # Make predictions\n",
        "    y_pred = pipeline.predict(X_val)\n",
        "    y_pred_proba = pipeline.predict_proba(X_val)[:, 1]\n",
        "\n",
        "    # Calculate scores\n",
        "    balanced_accuracy_scores.append(balanced_accuracy_score(y_val, y_pred))\n",
        "    roc_auc_scores.append(roc_auc_score(y_val, y_pred_proba))\n",
        "    average_precision_scores.append(average_precision_score(y_val, y_pred_proba))\n",
        "\n",
        "    print(f\"Fold {fold}:\")\n",
        "    print(f\"  Balanced Accuracy: {balanced_accuracy_scores[-1]:.4f}\")\n",
        "    print(f\"  ROC AUC: {roc_auc_scores[-1]:.4f}\")\n",
        "    print(f\"  Average Precision: {average_precision_scores[-1]:.4f}\")\n",
        "\n",
        "# Print the overall results\n",
        "print(\"\\nCross-validation results:\")\n",
        "print(f\"Balanced Accuracy: {np.mean(balanced_accuracy_scores):.4f} (+/- {np.std(balanced_accuracy_scores) * 2:.4f})\")\n",
        "print(f\"ROC AUC: {np.mean(roc_auc_scores):.4f} (+/- {np.std(roc_auc_scores) * 2:.4f})\")\n",
        "print(f\"Average Precision: {np.mean(average_precision_scores):.4f} (+/- {np.std(average_precision_scores) * 2:.4f})\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "cZqWaRDr61mL",
        "outputId": "d77b060e-d380-4978-c920-97d260f2cf64"
      },
      "execution_count": 38,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Fold 1:\n",
            "  Balanced Accuracy: 0.7493\n",
            "  ROC AUC: 0.9968\n",
            "  Average Precision: 1.0000\n",
            "Fold 2:\n",
            "  Balanced Accuracy: 0.7605\n",
            "  ROC AUC: 0.9944\n",
            "  Average Precision: 0.9999\n",
            "Fold 3:\n",
            "  Balanced Accuracy: 0.7172\n",
            "  ROC AUC: 0.9915\n",
            "  Average Precision: 0.9999\n",
            "Fold 4:\n",
            "  Balanced Accuracy: 0.7170\n",
            "  ROC AUC: 0.9932\n",
            "  Average Precision: 0.9999\n",
            "Fold 5:\n",
            "  Balanced Accuracy: 0.6953\n",
            "  ROC AUC: 0.9957\n",
            "  Average Precision: 1.0000\n",
            "\n",
            "Cross-validation results:\n",
            "Balanced Accuracy: 0.7278 (+/- 0.0475)\n",
            "ROC AUC: 0.9943 (+/- 0.0037)\n",
            "Average Precision: 0.9999 (+/- 0.0000)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Grid search optimization"
      ],
      "metadata": {
        "id": "_XUIxpRdKzf9"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.model_selection import cross_val_score\n",
        "import itertools\n",
        "\n",
        "# Define parameter grid\n",
        "param_grid = {\n",
        "    'n_estimators': [100, 200, 300],\n",
        "    'max_depth': [None, 10, 20, 30],\n",
        "    'min_samples_split': [2, 5, 10],\n",
        "    'min_samples_leaf': [1, 2, 4]\n",
        "}\n",
        "\n",
        "# Generate all combinations of parameters\n",
        "param_combinations = list(itertools.product(*param_grid.values()))\n",
        "\n",
        "best_score = -float('inf')\n",
        "best_params = None\n",
        "\n",
        "# Manually perform grid search\n",
        "for params in param_combinations:\n",
        "    # Create a new pipeline with current parameters\n",
        "    current_pipeline = Pipeline([\n",
        "        ('smote', SMOTE(sampling_strategy=0.35, random_state=42)),\n",
        "        ('undersampler', RandomUnderSampler(sampling_strategy=1.0, random_state=42)),\n",
        "        ('classifier', RandomForestClassifier(\n",
        "            n_estimators=params[0],\n",
        "            max_depth=params[1],\n",
        "            min_samples_split=params[2],\n",
        "            min_samples_leaf=params[3],\n",
        "            class_weight='balanced',\n",
        "            random_state=42\n",
        "        ))\n",
        "    ])\n",
        "\n",
        "    # Perform cross-validation\n",
        "    scores = cross_val_score(current_pipeline, X, y, cv=5, scoring='balanced_accuracy')\n",
        "    mean_score = scores.mean()\n",
        "\n",
        "    # Update best score and parameters if current is better\n",
        "    if mean_score > best_score:\n",
        "        best_score = mean_score\n",
        "        best_params = params\n",
        "\n",
        "    print(f\"Parameters: {params}, Score: {mean_score}\")\n",
        "\n",
        "print(f\"\\nBest parameters: {best_params}\")\n",
        "print(f\"Best cross-validation score: {best_score}\")\n",
        "\n",
        "# Create the best pipeline\n",
        "best_pipeline = Pipeline([\n",
        "    ('smote', SMOTE(sampling_strategy=0.35, random_state=42)),\n",
        "    ('undersampler', RandomUnderSampler(sampling_strategy=1.0, random_state=42)),\n",
        "    ('classifier', RandomForestClassifier(\n",
        "        n_estimators=best_params[0],\n",
        "        max_depth=best_params[1],\n",
        "        min_samples_split=best_params[2],\n",
        "        min_samples_leaf=best_params[3],\n",
        "        class_weight='balanced',\n",
        "        random_state=42\n",
        "    ))\n",
        "])\n",
        "\n",
        "# Fit the best pipeline\n",
        "best_pipeline.fit(X, y)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "yIeeLfSlBXI7",
        "outputId": "ee84da33-1d68-4cc3-8f82-82c20b4c2846"
      },
      "execution_count": 61,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Parameters: (100, None, 2, 1), Score: 0.6601958996148235\n",
            "Parameters: (100, None, 2, 2), Score: 0.6575723238043774\n",
            "Parameters: (100, None, 2, 4), Score: 0.6832200924981155\n",
            "Parameters: (100, None, 5, 1), Score: 0.6550882823515521\n",
            "Parameters: (100, None, 5, 2), Score: 0.6617703512425128\n",
            "Parameters: (100, None, 5, 4), Score: 0.6832200924981155\n",
            "Parameters: (100, None, 10, 1), Score: 0.6531768364259575\n",
            "Parameters: (100, None, 10, 2), Score: 0.6652185568886595\n",
            "Parameters: (100, None, 10, 4), Score: 0.6606836474980943\n",
            "Parameters: (100, 10, 2, 1), Score: 0.7538128573575538\n",
            "Parameters: (100, 10, 2, 2), Score: 0.7490530042380288\n",
            "Parameters: (100, 10, 2, 4), Score: 0.7528384007866634\n",
            "Parameters: (100, 10, 5, 1), Score: 0.7531383491639173\n",
            "Parameters: (100, 10, 5, 2), Score: 0.7575612641582747\n",
            "Parameters: (100, 10, 5, 4), Score: 0.7528384007866634\n",
            "Parameters: (100, 10, 10, 1), Score: 0.7454542837406529\n",
            "Parameters: (100, 10, 10, 2), Score: 0.7450421584057931\n",
            "Parameters: (100, 10, 10, 4), Score: 0.7454544241724976\n",
            "Parameters: (100, 20, 2, 1), Score: 0.667890060811074\n",
            "Parameters: (100, 20, 2, 2), Score: 0.6709738726297466\n",
            "Parameters: (100, 20, 2, 4), Score: 0.6855542931725662\n",
            "Parameters: (100, 20, 5, 1), Score: 0.6718902772293134\n",
            "Parameters: (100, 20, 5, 2), Score: 0.6761462302501122\n",
            "Parameters: (100, 20, 5, 4), Score: 0.6855542931725662\n",
            "Parameters: (100, 20, 10, 1), Score: 0.6663908946953685\n",
            "Parameters: (100, 20, 10, 2), Score: 0.6653415739080288\n",
            "Parameters: (100, 20, 10, 4), Score: 0.6765587768805064\n",
            "Parameters: (100, 30, 2, 1), Score: 0.659548594346173\n",
            "Parameters: (100, 30, 2, 2), Score: 0.6622950046145905\n",
            "Parameters: (100, 30, 2, 4), Score: 0.6784974819038248\n",
            "Parameters: (100, 30, 5, 1), Score: 0.6547135399737714\n",
            "Parameters: (100, 30, 5, 2), Score: 0.6574599783285577\n",
            "Parameters: (100, 30, 5, 4), Score: 0.6784974819038248\n",
            "Parameters: (100, 30, 10, 1), Score: 0.6532142895989589\n",
            "Parameters: (100, 30, 10, 2), Score: 0.6739245014401413\n",
            "Parameters: (100, 30, 10, 4), Score: 0.665106450146976\n",
            "Parameters: (200, None, 2, 1), Score: 0.6643938427938523\n",
            "Parameters: (200, None, 2, 2), Score: 0.6576473705822248\n",
            "Parameters: (200, None, 2, 4), Score: 0.6868933120891442\n",
            "Parameters: (200, None, 5, 1), Score: 0.6553131418214051\n",
            "Parameters: (200, None, 5, 2), Score: 0.6623325701330676\n",
            "Parameters: (200, None, 5, 4), Score: 0.6868933120891442\n",
            "Parameters: (200, None, 10, 1), Score: 0.6578994329770638\n",
            "Parameters: (200, None, 10, 2), Score: 0.6652935615369535\n",
            "Parameters: (200, None, 10, 4), Score: 0.6698392267301753\n",
            "Parameters: (200, 10, 2, 1), Score: 0.745267074048384\n",
            "Parameters: (200, 10, 2, 2), Score: 0.7449298971890804\n",
            "Parameters: (200, 10, 2, 4), Score: 0.7447048832441983\n",
            "Parameters: (200, 10, 5, 1), Score: 0.7492776671032991\n",
            "Parameters: (200, 10, 5, 2), Score: 0.74897785915789\n",
            "Parameters: (200, 10, 5, 4), Score: 0.7447048832441983\n",
            "Parameters: (200, 10, 10, 1), Score: 0.7457916712477236\n",
            "Parameters: (200, 10, 10, 2), Score: 0.7454544241724976\n",
            "Parameters: (200, 10, 10, 4), Score: 0.7451547004861954\n",
            "Parameters: (200, 20, 2, 1), Score: 0.6638045192806029\n",
            "Parameters: (200, 20, 2, 2), Score: 0.6673279261796262\n",
            "Parameters: (200, 20, 2, 4), Score: 0.6721734274046259\n",
            "Parameters: (200, 20, 5, 1), Score: 0.6592693009399793\n",
            "Parameters: (200, 20, 5, 2), Score: 0.6672631436929786\n",
            "Parameters: (200, 20, 5, 4), Score: 0.6721734274046259\n",
            "Parameters: (200, 20, 10, 1), Score: 0.6754715254518933\n",
            "Parameters: (200, 20, 10, 2), Score: 0.6794446232042534\n",
            "Parameters: (200, 20, 10, 4), Score: 0.6768585286531775\n",
            "Parameters: (200, 30, 2, 1), Score: 0.6599233788535073\n",
            "Parameters: (200, 30, 2, 2), Score: 0.6574974595879279\n",
            "Parameters: (200, 30, 2, 4), Score: 0.6783100896501577\n",
            "Parameters: (200, 30, 5, 1), Score: 0.6550133198328116\n",
            "Parameters: (200, 30, 5, 2), Score: 0.6624449717816251\n",
            "Parameters: (200, 30, 5, 4), Score: 0.6783100896501577\n",
            "Parameters: (200, 30, 10, 1), Score: 0.6581617737062869\n",
            "Parameters: (200, 30, 10, 2), Score: 0.6695289298026146\n",
            "Parameters: (200, 30, 10, 4), Score: 0.6699142032921004\n",
            "Parameters: (300, None, 2, 1), Score: 0.6602333949173783\n",
            "Parameters: (300, None, 2, 2), Score: 0.6577598143603358\n",
            "Parameters: (300, None, 2, 4), Score: 0.6747867810534257\n",
            "Parameters: (300, None, 5, 1), Score: 0.6598858835509525\n",
            "Parameters: (300, None, 5, 2), Score: 0.662444971781625\n",
            "Parameters: (300, None, 5, 4), Score: 0.6747867810534257\n",
            "Parameters: (300, None, 10, 1), Score: 0.6583491800031385\n",
            "Parameters: (300, None, 10, 2), Score: 0.6609831745798139\n",
            "Parameters: (300, None, 10, 4), Score: 0.6698495331509285\n",
            "Parameters: (300, 10, 2, 1), Score: 0.7449297427140511\n",
            "Parameters: (300, 10, 2, 2), Score: 0.7497272877407137\n",
            "Parameters: (300, 10, 2, 4), Score: 0.7446298083799818\n",
            "Parameters: (300, 10, 5, 1), Score: 0.7494274517089357\n",
            "Parameters: (300, 10, 5, 2), Score: 0.7490527514607083\n",
            "Parameters: (300, 10, 5, 4), Score: 0.7446298083799818\n",
            "Parameters: (300, 10, 10, 1), Score: 0.7452669336165393\n",
            "Parameters: (300, 10, 10, 2), Score: 0.7453419242216488\n",
            "Parameters: (300, 10, 10, 4), Score: 0.7447797474606476\n",
            "Parameters: (300, 20, 2, 1), Score: 0.6591841443459611\n",
            "Parameters: (300, 20, 2, 2), Score: 0.6669530854995541\n",
            "Parameters: (300, 20, 2, 4), Score: 0.6768960941716546\n",
            "Parameters: (300, 20, 5, 1), Score: 0.6676651451684832\n",
            "Parameters: (300, 20, 5, 2), Score: 0.6758463520887806\n",
            "Parameters: (300, 20, 5, 4), Score: 0.6768960941716546\n",
            "Parameters: (300, 20, 10, 1), Score: 0.6711509725058449\n",
            "Parameters: (300, 20, 10, 2), Score: 0.6749843392960013\n",
            "Parameters: (300, 20, 10, 4), Score: 0.6810939530915764\n",
            "Parameters: (300, 30, 2, 1), Score: 0.6600357805020648\n",
            "Parameters: (300, 30, 2, 2), Score: 0.6577223471441499\n",
            "Parameters: (300, 30, 2, 4), Score: 0.6746743653616838\n",
            "Parameters: (300, 30, 5, 1), Score: 0.6596235287785447\n",
            "Parameters: (300, 30, 5, 2), Score: 0.662145135749847\n",
            "Parameters: (300, 30, 5, 4), Score: 0.6746743653616838\n",
            "Parameters: (300, 30, 10, 1), Score: 0.6583491800031385\n",
            "Parameters: (300, 30, 10, 2), Score: 0.660870730801703\n",
            "Parameters: (300, 30, 10, 4), Score: 0.6699244816264847\n",
            "\n",
            "Best parameters: (100, 10, 5, 2)\n",
            "Best cross-validation score: 0.7575612641582747\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "Pipeline(steps=[('smote', SMOTE(random_state=42, sampling_strategy=0.35)),\n",
              "                ('undersampler',\n",
              "                 RandomUnderSampler(random_state=42, sampling_strategy=1.0)),\n",
              "                ('classifier',\n",
              "                 RandomForestClassifier(class_weight='balanced', max_depth=10,\n",
              "                                        min_samples_leaf=2, min_samples_split=5,\n",
              "                                        random_state=42))])"
            ],
            "text/html": [
              "<style>#sk-container-id-10 {color: black;}#sk-container-id-10 pre{padding: 0;}#sk-container-id-10 div.sk-toggleable {background-color: white;}#sk-container-id-10 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-10 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-10 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-10 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-10 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-10 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-10 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-10 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-10 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-10 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-10 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-10 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-10 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-10 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-10 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-10 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-10 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-10 div.sk-item {position: relative;z-index: 1;}#sk-container-id-10 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-10 div.sk-item::before, #sk-container-id-10 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-10 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-10 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-10 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-10 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-10 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-10 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-10 div.sk-label-container {text-align: center;}#sk-container-id-10 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-10 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-10\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>Pipeline(steps=[(&#x27;smote&#x27;, SMOTE(random_state=42, sampling_strategy=0.35)),\n",
              "                (&#x27;undersampler&#x27;,\n",
              "                 RandomUnderSampler(random_state=42, sampling_strategy=1.0)),\n",
              "                (&#x27;classifier&#x27;,\n",
              "                 RandomForestClassifier(class_weight=&#x27;balanced&#x27;, max_depth=10,\n",
              "                                        min_samples_leaf=2, min_samples_split=5,\n",
              "                                        random_state=42))])</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item sk-dashed-wrapped\"><div class=\"sk-label-container\"><div class=\"sk-label sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-37\" type=\"checkbox\" ><label for=\"sk-estimator-id-37\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">Pipeline</label><div class=\"sk-toggleable__content\"><pre>Pipeline(steps=[(&#x27;smote&#x27;, SMOTE(random_state=42, sampling_strategy=0.35)),\n",
              "                (&#x27;undersampler&#x27;,\n",
              "                 RandomUnderSampler(random_state=42, sampling_strategy=1.0)),\n",
              "                (&#x27;classifier&#x27;,\n",
              "                 RandomForestClassifier(class_weight=&#x27;balanced&#x27;, max_depth=10,\n",
              "                                        min_samples_leaf=2, min_samples_split=5,\n",
              "                                        random_state=42))])</pre></div></div></div><div class=\"sk-serial\"><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-38\" type=\"checkbox\" ><label for=\"sk-estimator-id-38\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">SMOTE</label><div class=\"sk-toggleable__content\"><pre>SMOTE(random_state=42, sampling_strategy=0.35)</pre></div></div></div><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-39\" type=\"checkbox\" ><label for=\"sk-estimator-id-39\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">RandomUnderSampler</label><div class=\"sk-toggleable__content\"><pre>RandomUnderSampler(random_state=42, sampling_strategy=1.0)</pre></div></div></div><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-40\" type=\"checkbox\" ><label for=\"sk-estimator-id-40\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">RandomForestClassifier</label><div class=\"sk-toggleable__content\"><pre>RandomForestClassifier(class_weight=&#x27;balanced&#x27;, max_depth=10,\n",
              "                       min_samples_leaf=2, min_samples_split=5,\n",
              "                       random_state=42)</pre></div></div></div></div></div></div></div>"
            ]
          },
          "metadata": {},
          "execution_count": 61
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "\"\"\"\n",
        "Pipeline(steps=[('smote', SMOTE(random_state=42, sampling_strategy=0.35)),\n",
        "                ('undersampler',\n",
        "                 RandomUnderSampler(random_state=42, sampling_strategy=1.0)),\n",
        "                ('classifier',\n",
        "                 RandomForestClassifier(class_weight='balanced', max_depth=10,\n",
        "                                        min_samples_leaf=2, min_samples_split=5,\n",
        "                                        random_state=42))])\n",
        "\n",
        "SMOTE\n",
        "SMOTE(random_state=42, sampling_strategy=0.35)\n",
        "\n",
        "RandomUnderSampler\n",
        "RandomUnderSampler(random_state=42, sampling_strategy=1.0)\n",
        "\n",
        "RandomForestClassifier\n",
        "RandomForestClassifier(class_weight='balanced', max_depth=10,\n",
        "                       min_samples_leaf=2, min_samples_split=5,\n",
        "                       random_state=42)\n",
        "\"\"\"\n",
        "\n",
        "from imblearn.pipeline import make_pipeline\n",
        "from imblearn.over_sampling import SMOTE\n",
        "from imblearn.under_sampling import RandomUnderSampler\n",
        "from sklearn.ensemble import RandomForestClassifier\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.metrics import classification_report, balanced_accuracy_score\n",
        "\n",
        "# Assuming you have your features X and target y already defined\n",
        "# Encode labels\n",
        "le = LabelEncoder()\n",
        "df['label_encoded'] = le.fit_transform(df['label'])\n",
        "\n",
        "# Split data\n",
        "X = np.array(df['message_vector'].tolist())\n",
        "y = df['label_encoded'].values\n",
        "\n",
        "\n",
        "# Split the data into training and testing sets\n",
        "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
        "\n",
        "# Split the data into training and testing sets\n",
        "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
        "\n",
        "# Split the data into training and testing sets\n",
        "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
        "\n",
        "# Create the pipeline using make_pipeline\n",
        "pipeline = make_pipeline(\n",
        "    SMOTE(random_state=42, sampling_strategy=0.35),\n",
        "    RandomUnderSampler(random_state=42, sampling_strategy=1.0),\n",
        "    RandomForestClassifier(\n",
        "        class_weight='balanced',\n",
        "        max_depth=10,\n",
        "        min_samples_leaf=2,\n",
        "        min_samples_split=5,\n",
        "        random_state=42\n",
        "    )\n",
        ")\n",
        "\n",
        "# Fit the pipeline\n",
        "pipeline.fit(X_train, y_train)\n",
        "\n",
        "# Use the fitted pipeline to make predictions\n",
        "y_pred = pipeline.predict(X_test)\n",
        "\n",
        "# Evaluate the model\n",
        "print(classification_report(y_test, y_pred))\n",
        "print(f\"Balanced Accuracy: {balanced_accuracy_score(y_test, y_pred)}\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "saqEW4G2HbI3",
        "outputId": "d149844d-0cf7-4e33-89d9-cadf77890678"
      },
      "execution_count": 90,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "              precision    recall  f1-score   support\n",
            "\n",
            "           0       0.78      0.72      0.75        25\n",
            "           1       1.00      1.00      1.00      2666\n",
            "\n",
            "    accuracy                           1.00      2691\n",
            "   macro avg       0.89      0.86      0.87      2691\n",
            "weighted avg       1.00      1.00      1.00      2691\n",
            "\n",
            "Balanced Accuracy: 0.8590622655663915\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay\n",
        "import matplotlib.pyplot as plt\n",
        "\n",
        "# Make predictions\n",
        "y_pred = pipeline.predict(X_test)\n",
        "\n",
        "# Create the confusion matrix\n",
        "cm = confusion_matrix(y_test, y_pred)\n",
        "\n",
        "# Create a ConfusionMatrixDisplay object\n",
        "disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=['good', 'bad'])\n",
        "\n",
        "# Plot the confusion matrix\n",
        "plt.figure(figsize=(10, 7))\n",
        "disp.plot(cmap='Blues', values_format='d')\n",
        "plt.title('Confusion Matrix')\n",
        "plt.show()\n",
        "\n",
        "# Print the confusion matrix\n",
        "print(\"Confusion Matrix:\")\n",
        "print(cm)\n",
        "\n",
        "# Calculate and print additional metrics\n",
        "tn, fp, fn, tp = cm.ravel()\n",
        "precision = tp / (tp + fp)\n",
        "recall = tp / (tp + fn)\n",
        "f1_score = 2 * (precision * recall) / (precision + recall)\n",
        "\n",
        "print(f\"\\nPrecision: {precision:.4f}\")\n",
        "print(f\"Recall: {recall:.4f}\")\n",
        "print(f\"F1-score: {f1_score:.4f}\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 617
        },
        "id": "raf1OKv4_E23",
        "outputId": "6f7ab778-99af-401d-a8e0-2d8bff230902"
      },
      "execution_count": 91,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 1000x700 with 0 Axes>"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 640x480 with 2 Axes>"
            ],
            "image/png": "[encoded data, 25104 characters]\n"
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Confusion Matrix:\n",
            "[[  18    7]\n",
            " [   5 2661]]\n",
            "\n",
            "Precision: 0.9974\n",
            "Recall: 0.9981\n",
            "F1-score: 0.9978\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.model_selection import StratifiedKFold\n",
        "from sklearn.metrics import balanced_accuracy_score, roc_auc_score, average_precision_score\n",
        "import numpy as np\n",
        "\n",
        "# Define the number of folds\n",
        "n_splits = 5\n",
        "\n",
        "# Create a StratifiedKFold object\n",
        "skf = StratifiedKFold(n_splits=n_splits, shuffle=True, random_state=42)\n",
        "\n",
        "# Initialize lists to store the scores\n",
        "balanced_accuracy_scores = []\n",
        "roc_auc_scores = []\n",
        "average_precision_scores = []\n",
        "\n",
        "# Perform cross-validation manually\n",
        "for fold, (train_index, val_index) in enumerate(skf.split(X, y), 1):\n",
        "    X_train, X_val = X[train_index], X[val_index]\n",
        "    y_train, y_val = y[train_index], y[val_index]\n",
        "\n",
        "    # Fit the pipeline\n",
        "    pipeline.fit(X_train, y_train)\n",
        "\n",
        "    # Make predictions\n",
        "    y_pred = pipeline.predict(X_val)\n",
        "    y_pred_proba = pipeline.predict_proba(X_val)[:, 1]\n",
        "\n",
        "    # Calculate scores\n",
        "    balanced_accuracy_scores.append(balanced_accuracy_score(y_val, y_pred))\n",
        "    roc_auc_scores.append(roc_auc_score(y_val, y_pred_proba))\n",
        "    average_precision_scores.append(average_precision_score(y_val, y_pred_proba))\n",
        "\n",
        "    print(f\"Fold {fold}:\")\n",
        "    print(f\"  Balanced Accuracy: {balanced_accuracy_scores[-1]:.4f}\")\n",
        "    print(f\"  ROC AUC: {roc_auc_scores[-1]:.4f}\")\n",
        "    print(f\"  Average Precision: {average_precision_scores[-1]:.4f}\")\n",
        "\n",
        "# Print the overall results\n",
        "print(\"\\nCross-validation results:\")\n",
        "print(f\"Balanced Accuracy: {np.mean(balanced_accuracy_scores):.4f} (+/- {np.std(balanced_accuracy_scores) * 2:.4f})\")\n",
        "print(f\"ROC AUC: {np.mean(roc_auc_scores):.4f} (+/- {np.std(roc_auc_scores) * 2:.4f})\")\n",
        "print(f\"Average Precision: {np.mean(average_precision_scores):.4f} (+/- {np.std(average_precision_scores) * 2:.4f})\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "WAJiYO5dK7eL",
        "outputId": "21d68432-3b20-4fca-9775-bdf302ce8c0e"
      },
      "execution_count": 63,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Fold 1:\n",
            "  Balanced Accuracy: 0.9761\n",
            "  ROC AUC: 0.9994\n",
            "  Average Precision: 1.0000\n",
            "Fold 2:\n",
            "  Balanced Accuracy: 0.8679\n",
            "  ROC AUC: 0.9965\n",
            "  Average Precision: 1.0000\n",
            "Fold 3:\n",
            "  Balanced Accuracy: 0.8686\n",
            "  ROC AUC: 0.9984\n",
            "  Average Precision: 1.0000\n",
            "Fold 4:\n",
            "  Balanced Accuracy: 0.8692\n",
            "  ROC AUC: 0.9970\n",
            "  Average Precision: 1.0000\n",
            "Fold 5:\n",
            "  Balanced Accuracy: 0.9115\n",
            "  ROC AUC: 0.9979\n",
            "  Average Precision: 1.0000\n",
            "\n",
            "Cross-validation results:\n",
            "Balanced Accuracy: 0.8987 (+/- 0.0843)\n",
            "ROC AUC: 0.9979 (+/- 0.0020)\n",
            "Average Precision: 1.0000 (+/- 0.0000)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "test_message_benign = random_good_message\n",
        "test_message_bad = random_bad_message\n",
        "\n",
        "\n",
        "from tokenizers import Tokenizer\n",
        "import torch\n",
        "import numpy as np\n",
        "import polars as pl\n",
        "import numpy as np\n",
        "\n",
        "# Load the custom tokenizer\n",
        "tokenizer = Tokenizer.from_file(\"log_tokenizer.json\")\n",
        "\n",
        "# Define the device (assuming you're using PyTorch and want to specify CPU or GPU)\n",
        "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
        "\n",
        "vector_good = vectorize_text(test_message_benign).flatten()\n",
        "print(len(vector_good))\n",
        "\n",
        "\n",
        "# Assuming 'vector' is your input\n",
        "vector_good = np.array(vector_good)\n",
        "vector_2d_good = vector_good.reshape(1, -1)\n",
        "\n",
        "# Class prediction\n",
        "prediction = pipeline.predict(vector_2d_good)\n",
        "print(\"Predicted class:\", prediction[0])\n",
        "\n",
        "# Probability prediction\n",
        "probabilities = pipeline.predict_proba(vector_2d_good)\n",
        "print(\"Class probabilities:\", probabilities[0])\n",
        "\n",
        "\n",
        "vector_bad = vectorize_text(test_message_bad).flatten()\n",
        "print(len(vector_bad))\n",
        "\n",
        "# Assuming 'vector' is your input\n",
        "vector_bad = np.array(vector_bad)\n",
        "vector_2d_bad = vector_bad.reshape(1, -1)\n",
        "\n",
        "# Class prediction\n",
        "prediction = pipeline.predict(vector_2d_bad)\n",
        "print(\"Predicted class:\", prediction[0])\n",
        "\n",
        "# Probability prediction\n",
        "probabilities = pipeline.predict_proba(vector_2d_bad)\n",
        "print(\"Class probabilities:\", probabilities[0])\n",
        "\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "RbXSx4Go-6pd",
        "outputId": "6fbe80e4-4818-42dd-d5b6-895cfbcce41f"
      },
      "execution_count": 95,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "30000\n",
            "Predicted class: 1\n",
            "Class probabilities: [0. 1.]\n",
            "30000\n",
            "Predicted class: 0\n",
            "Class probabilities: [0.68148054 0.31851946]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Tpot (Supervised)"
      ],
      "metadata": {
        "id": "ZWRH59wKLaAX"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.preprocessing import StandardScaler\n",
        "from sklearn.impute import SimpleImputer\n",
        "from sklearn.ensemble import RandomForestClassifier\n",
        "from sklearn.metrics import make_scorer, confusion_matrix, classification_report\n",
        "from imblearn.over_sampling import SMOTE\n",
        "from imblearn.under_sampling import RandomUnderSampler\n",
        "from imblearn.pipeline import Pipeline as ImbPipeline\n",
        "from tpot import TPOTClassifier\n",
        "from sklearn.decomposition import TruncatedSVD\n",
        "\n",
        "def print_step_info(X, y, step_name):\n",
        "    print(f\"\\n--- {step_name} ---\")\n",
        "    print(f\"X shape: {X.shape}\")\n",
        "    print(f\"y shape: {y.shape}\")\n",
        "    print(f\"Class distribution: {np.bincount(y)}\")\n",
        "\n",
        "def custom_scorer(y_true, y_pred):\n",
        "    cm = confusion_matrix(y_true, y_pred)\n",
        "    tn, fp, fn, tp = cm.ravel()\n",
        "    if (tp + fn) == 0 or (tn + fp) == 0:\n",
        "        return 0.0\n",
        "    recall = tp / (tp + fn + 1e-8)\n",
        "    specificity = tn / (tn + fp + 1e-8)\n",
        "    recall_weight = 1.0\n",
        "    specificity_weight = 2.0\n",
        "    score = (recall_weight * recall + specificity_weight * specificity) / (recall_weight + specificity_weight)\n",
        "    return score\n",
        "\n",
        "custom_scorer_obj = make_scorer(custom_scorer, greater_is_better=True)\n",
        "\n",
        "# Assuming you have your features X and target y already defined\n",
        "# Encode labels\n",
        "le = LabelEncoder()\n",
        "df['label_encoded'] = le.fit_transform(df['label'])\n",
        "\n",
        "# Split data\n",
        "X = np.array(df['message_vector'].tolist())\n",
        "y = df['label_encoded'].values\n",
        "\n",
        "print_step_info(X, y, \"Original Data\")\n",
        "\n",
        "# Step 1: Preprocessing\n",
        "imputer = SimpleImputer(strategy='mean')\n",
        "scaler = StandardScaler()\n",
        "pca = TruncatedSVD(n_components=100, random_state=42)  # Reduce to 100 components\n",
        "\n",
        "X = imputer.fit_transform(X)\n",
        "X = scaler.fit_transform(X)\n",
        "X = pca.fit_transform(X)\n",
        "\n",
        "print_step_info(X, y, \"After Preprocessing\")\n",
        "\n",
        "# Step 2: Split the data\n",
        "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)\n",
        "print_step_info(X_train, y_train, \"Training Data\")\n",
        "\n",
        "# Step 3: Initial model on imbalanced data\n",
        "initial_model = RandomForestClassifier(n_estimators=100, class_weight='balanced', random_state=42, n_jobs=-1)\n",
        "initial_model.fit(X_train, y_train)\n",
        "y_pred_initial = initial_model.predict(X_test)\n",
        "print(\"\\nInitial Model Performance:\")\n",
        "print(classification_report(y_test, y_pred_initial, zero_division=0))\n",
        "print(\"Custom Score:\", custom_scorer(y_test, y_pred_initial))\n",
        "\n",
        "# Step 4: Resampling\n",
        "smote = SMOTE(sampling_strategy=0.5, random_state=42)\n",
        "rus = RandomUnderSampler(sampling_strategy=0.5, random_state=42)\n",
        "X_resampled, y_resampled = rus.fit_resample(*smote.fit_resample(X_train, y_train))\n",
        "print_step_info(X_resampled, y_resampled, \"Resampled Data\")\n",
        "\n",
        "# Step 5: Model on resampled data\n",
        "resampled_model = RandomForestClassifier(n_estimators=100, class_weight='balanced', random_state=42, n_jobs=-1)\n",
        "resampled_model.fit(X_resampled, y_resampled)\n",
        "y_pred_resampled = resampled_model.predict(X_test)\n",
        "print(\"\\nResampled Model Performance:\")\n",
        "print(classification_report(y_test, y_pred_resampled, zero_division=0))\n",
        "print(\"Custom Score:\", custom_scorer(y_test, y_pred_resampled))\n",
        "\n",
        "# Step 6: Create a new dataset with original minority samples and top predicted minority samples\n",
        "y_pred_proba = resampled_model.predict_proba(X_train)[:, 1]\n",
        "minority_indices = np.where(y_train == 0)[0]\n",
        "predicted_minority_indices = np.argsort(y_pred_proba)[-len(minority_indices)*10:]\n",
        "selected_indices = np.union1d(minority_indices, predicted_minority_indices)\n",
        "\n",
        "X_selected = X_train[selected_indices]\n",
        "y_selected = y_train[selected_indices]\n",
        "print_step_info(X_selected, y_selected, \"Selected Data for Final Model\")\n",
        "\n",
        "# Step 7: Final TPOT optimization\n",
        "tpot_config = {\n",
        "    'sklearn.ensemble.RandomForestClassifier': {\n",
        "        'n_estimators': [100, 200, 500],\n",
        "        'max_depth': [None, 5, 10, 20],\n",
        "        'min_samples_split': [2, 5, 10],\n",
        "        'min_samples_leaf': [1, 2, 4],\n",
        "        'class_weight': ['balanced', 'balanced_subsample']\n",
        "    },\n",
        "    'xgboost.XGBClassifier': {\n",
        "        'n_estimators': [100, 200, 500],\n",
        "        'max_depth': [3, 5, 7, 9],\n",
        "        'learning_rate': [0.01, 0.1, 0.3],\n",
        "        'subsample': [0.5, 0.7, 1.0],\n",
        "        'scale_pos_weight': [1, 10, 100]\n",
        "    },\n",
        "    'imblearn.ensemble.BalancedRandomForestClassifier': {\n",
        "        'n_estimators': [100, 200, 500],\n",
        "        'replacement': [True, False]\n",
        "    },\n",
        "    'imblearn.ensemble.EasyEnsembleClassifier': {\n",
        "        'n_estimators': [10, 20, 30, 50],\n",
        "        'replacement': [True, False]\n",
        "    }\n",
        "}\n",
        "\n",
        "tpot = TPOTClassifier(\n",
        "    config_dict=tpot_config,\n",
        "    generations=1,\n",
        "    population_size=20,\n",
        "    verbosity=2,\n",
        "    scoring=custom_scorer_obj,\n",
        "    random_state=42,\n",
        "    n_jobs=-1,\n",
        "    max_time_mins=60,\n",
        "    max_eval_time_mins=10\n",
        ")\n",
        "\n",
        "try:\n",
        "    tpot.fit(X_selected, y_selected)\n",
        "    y_pred_tpot = tpot.predict(X_test)\n",
        "    print(\"\\nTPOT Model Performance:\")\n",
        "    print(classification_report(y_test, y_pred_tpot, zero_division=0))\n",
        "    print(\"Custom Score:\", custom_scorer(y_test, y_pred_tpot))\n",
        "    print(\"\\nConfusion Matrix:\")\n",
        "    print(confusion_matrix(y_test, y_pred_tpot))\n",
        "    tpot.export('tpot_best_pipeline.py')\n",
        "    print(\"\\nBest pipeline exported to 'tpot_best_pipeline.py'\")\n",
        "except Exception as e:\n",
        "    print(f\"An error occurred during TPOT optimization: {str(e)}\")\n",
        "\n",
        "# Final evaluation\n",
        "print(\"\\nFinal Evaluation:\")\n",
        "print(\"Initial Model Custom Score:\", custom_scorer(y_test, y_pred_initial))\n",
        "print(\"Resampled Model Custom Score:\", custom_scorer(y_test, y_pred_resampled))\n",
        "if 'y_pred_tpot' in locals():\n",
        "    print(\"TPOT Model Custom Score:\", custom_scorer(y_test, y_pred_tpot))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000,
          "referenced_widgets": [
            "0ee9d77e31c343d2b226c9e1c370899a",
            "cefbf3ec854e463eac3047d7f2366a9b",
            "5d5a04539517439c9a47f725bbfca641",
            "487df5716a1f42b9ad08a05300882448",
            "f6f95cf2eb1f43cdbb1be5a1ffc19621",
            "a8b2545d7d94490b8df9d8a63d7fde2d",
            "18b7438e17ef4851aa9c8d0dfc52f2d5",
            "939ebe26aaf74df78c81c255aefcc7e5",
            "c5677148554a4e65b74ae9fc95ae4c37",
            "328be8dce5cf4b2a8418e7693f1829c0",
            "48d9d503aebd44578cb545fdb4b28776"
          ]
        },
        "id": "TnChV008alMz",
        "outputId": "2e7242bb-41eb-4657-9aba-80bf41b9e218"
      },
      "execution_count": 137,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "--- Original Data ---\n",
            "X shape: (13455, 30000)\n",
            "y shape: (13455,)\n",
            "Class distribution: [  114 13341]\n",
            "\n",
            "--- After Preprocessing ---\n",
            "X shape: (13455, 100)\n",
            "y shape: (13455,)\n",
            "Class distribution: [  114 13341]\n",
            "\n",
            "--- Training Data ---\n",
            "X shape: (10764, 100)\n",
            "y shape: (10764,)\n",
            "Class distribution: [   91 10673]\n",
            "\n",
            "Initial Model Performance:\n",
            "              precision    recall  f1-score   support\n",
            "\n",
            "           0       0.00      0.00      0.00        23\n",
            "           1       0.99      1.00      1.00      2668\n",
            "\n",
            "    accuracy                           0.99      2691\n",
            "   macro avg       0.50      0.50      0.50      2691\n",
            "weighted avg       0.98      0.99      0.99      2691\n",
            "\n",
            "Custom Score: 0.333333333332084\n",
            "\n",
            "--- Resampled Data ---\n",
            "X shape: (16008, 100)\n",
            "y shape: (16008,)\n",
            "Class distribution: [ 5336 10672]\n",
            "\n",
            "Resampled Model Performance:\n",
            "              precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.22      0.36        23\n",
            "           1       0.99      1.00      1.00      2668\n",
            "\n",
            "    accuracy                           0.99      2691\n",
            "   macro avg       1.00      0.61      0.68      2691\n",
            "weighted avg       0.99      0.99      0.99      2691\n",
            "\n",
            "Custom Score: 0.47826086950095603\n",
            "\n",
            "--- Selected Data for Final Model ---\n",
            "X shape: (1001, 100)\n",
            "y shape: (1001,)\n",
            "Class distribution: [ 91 910]\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/20 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "0ee9d77e31c343d2b226c9e1c370899a"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 0.9886446882605258\n",
            "\n",
            "Best pipeline: BalancedRandomForestClassifier(input_matrix, n_estimators=500, replacement=False)\n",
            "\n",
            "TPOT Model Performance:\n",
            "              precision    recall  f1-score   support\n",
            "\n",
            "           0       0.07      1.00      0.14        23\n",
            "           1       1.00      0.89      0.94      2668\n",
            "\n",
            "    accuracy                           0.89      2691\n",
            "   macro avg       0.54      0.95      0.54      2691\n",
            "weighted avg       0.99      0.89      0.94      2691\n",
            "\n",
            "Custom Score: 0.9635182405885926\n",
            "\n",
            "Confusion Matrix:\n",
            "[[  23    0]\n",
            " [ 292 2376]]\n",
            "\n",
            "Best pipeline exported to 'tpot_best_pipeline.py'\n",
            "\n",
            "Final Evaluation:\n",
            "Initial Model Custom Score: 0.333333333332084\n",
            "Resampled Model Custom Score: 0.47826086950095603\n",
            "TPOT Model Custom Score: 0.9635182405885926\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay\n",
        "import matplotlib.pyplot as plt\n",
        "\n",
        "# Make predictions\n",
        "y_pred = tpot.predict(X_test)\n",
        "\n",
        "# Create the confusion matrix\n",
        "cm = confusion_matrix(y_test, y_pred)\n",
        "\n",
        "# Create a ConfusionMatrixDisplay object\n",
        "disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=['negative', 'positive'])\n",
        "\n",
        "# Plot the confusion matrix\n",
        "plt.figure(figsize=(10, 7))\n",
        "disp.plot(cmap='Blues', values_format='d')\n",
        "plt.title('Confusion Matrix')\n",
        "plt.show()\n",
        "\n",
        "# Print the confusion matrix\n",
        "print(\"Confusion Matrix:\")\n",
        "print(cm)\n",
        "\n",
        "# Calculate and print additional metrics\n",
        "tn, fp, fn, tp = cm.ravel()\n",
        "precision = tp / (tp + fp) if (tp + fp) > 0 else 0\n",
        "recall = tp / (tp + fn) if (tp + fn) > 0 else 0\n",
        "f1_score = 2 * (precision * recall) / (precision + recall) if (precision + recall) > 0 else 0\n",
        "\n",
        "print(f\"\\nPrecision: {precision:.4f}\")\n",
        "print(f\"Recall: {recall:.4f}\")\n",
        "print(f\"F1-score: {f1_score:.4f}\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 617
        },
        "id": "top9wzRCdAKK",
        "outputId": "decb8210-d1fc-4452-bc9c-ca6962caff0f"
      },
      "execution_count": 105,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 1000x700 with 0 Axes>"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 640x480 with 2 Axes>"
            ],
            "image/png": "[encoded data, 28220 characters]\n"
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Confusion Matrix:\n",
            "[[  23    0]\n",
            " [ 292 2376]]\n",
            "\n",
            "Precision: 1.0000\n",
            "Recall: 0.8906\n",
            "F1-score: 0.9421\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.model_selection import StratifiedKFold\n",
        "from sklearn.metrics import balanced_accuracy_score, roc_auc_score, average_precision_score\n",
        "import numpy as np\n",
        "\n",
        "# Define the number of folds\n",
        "n_splits = 5\n",
        "\n",
        "# Create a StratifiedKFold object\n",
        "skf = StratifiedKFold(n_splits=n_splits, shuffle=True, random_state=42)\n",
        "\n",
        "# Initialize lists to store the scores\n",
        "balanced_accuracy_scores = []\n",
        "roc_auc_scores = []\n",
        "average_precision_scores = []\n",
        "\n",
        "# Perform cross-validation\n",
        "for fold, (train_index, val_index) in enumerate(skf.split(X, y), 1):\n",
        "    X_val, y_val = X[val_index], y[val_index]\n",
        "\n",
        "    # Make predictions using the existing TPOT model\n",
        "    y_pred = tpot.predict(X_val)\n",
        "    y_pred_proba = tpot.predict_proba(X_val)[:, 1]\n",
        "\n",
        "    # Calculate scores\n",
        "    balanced_accuracy_scores.append(balanced_accuracy_score(y_val, y_pred))\n",
        "    roc_auc_scores.append(roc_auc_score(y_val, y_pred_proba))\n",
        "    average_precision_scores.append(average_precision_score(y_val, y_pred_proba))\n",
        "\n",
        "    print(f\"Fold {fold}:\")\n",
        "    print(f\"  Balanced Accuracy: {balanced_accuracy_scores[-1]:.4f}\")\n",
        "    print(f\"  ROC AUC: {roc_auc_scores[-1]:.4f}\")\n",
        "    print(f\"  Average Precision: {average_precision_scores[-1]:.4f}\")\n",
        "\n",
        "# Print the overall results\n",
        "print(\"\\nCross-validation results:\")\n",
        "print(f\"Balanced Accuracy: {np.mean(balanced_accuracy_scores):.4f} (+/- {np.std(balanced_accuracy_scores) * 2:.4f})\")\n",
        "print(f\"ROC AUC: {np.mean(roc_auc_scores):.4f} (+/- {np.std(roc_auc_scores) * 2:.4f})\")\n",
        "print(f\"Average Precision: {np.mean(average_precision_scores):.4f} (+/- {np.std(average_precision_scores) * 2:.4f})\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "nmu5z7OVdQHA",
        "outputId": "8193a942-2d4f-45b6-d1dc-e0dfed3e1d6c"
      },
      "execution_count": 77,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Fold 1:\n",
            "  Balanced Accuracy: 0.9507\n",
            "  ROC AUC: 0.9996\n",
            "  Average Precision: 1.0000\n",
            "Fold 2:\n",
            "  Balanced Accuracy: 0.9472\n",
            "  ROC AUC: 0.9963\n",
            "  Average Precision: 1.0000\n",
            "Fold 3:\n",
            "  Balanced Accuracy: 0.9400\n",
            "  ROC AUC: 0.9982\n",
            "  Average Precision: 1.0000\n",
            "Fold 4:\n",
            "  Balanced Accuracy: 0.9457\n",
            "  ROC AUC: 1.0000\n",
            "  Average Precision: 1.0000\n",
            "Fold 5:\n",
            "  Balanced Accuracy: 0.9468\n",
            "  ROC AUC: 0.9956\n",
            "  Average Precision: 1.0000\n",
            "\n",
            "Cross-validation results:\n",
            "Balanced Accuracy: 0.9461 (+/- 0.0069)\n",
            "ROC AUC: 0.9979 (+/- 0.0035)\n",
            "Average Precision: 1.0000 (+/- 0.0000)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "from sklearn.preprocessing import StandardScaler\n",
        "from sklearn.impute import SimpleImputer\n",
        "from sklearn.decomposition import TruncatedSVD\n",
        "\n",
        "# Assume these are saved from the training process\n",
        "saved_imputer = imputer  # The SimpleImputer used in training\n",
        "saved_scaler = scaler    # The StandardScaler used in training\n",
        "saved_pca = pca          # The TruncatedSVD (PCA) used in training\n",
        "\n",
        "# Vectorize the messages\n",
        "vector1 = vectorize_text(random_good_message)\n",
        "vector2 = vectorize_text(random_bad_message)\n",
        "\n",
        "print(\"Shape of vector1:\", vector1.shape)\n",
        "print(\"Shape of vector2:\", vector2.shape)\n",
        "\n",
        "# Combine the vectors\n",
        "X_new = np.vstack((vector1, vector2))\n",
        "\n",
        "print(\"Shape of X_new before preprocessing:\", X_new.shape)\n",
        "\n",
        "# Apply the saved preprocessing steps\n",
        "X_new = saved_imputer.transform(X_new)\n",
        "print(\"Shape after imputation:\", X_new.shape)\n",
        "\n",
        "X_new = saved_scaler.transform(X_new)\n",
        "print(\"Shape after scaling:\", X_new.shape)\n",
        "\n",
        "X_new = saved_pca.transform(X_new)\n",
        "print(\"Shape after PCA:\", X_new.shape)\n",
        "\n",
        "# Ensure X_new has exactly 100 features\n",
        "assert X_new.shape[1] == 100, f\"X_new has {X_new.shape[1]} features instead of 100\"\n",
        "\n",
        "# Make predictions using your TPOT model\n",
        "predictions = tpot.predict(X_new)\n",
        "probabilities = tpot.predict_proba(X_new)\n",
        "\n",
        "# Print results\n",
        "for i, (pred, prob) in enumerate(zip(predictions, probabilities)):\n",
        "    print(f\"Message {i+1}:\")\n",
        "    print(f\"Predicted class: {pred}\")\n",
        "    print(f\"Class probabilities: {prob}\")\n",
        "    print()\n",
        "\n",
        "# Print the shape of X_new for final confirmation\n",
        "print(f\"Final shape of X_new: {X_new.shape}\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "_AkVOj7ehjcQ",
        "outputId": "b4cd08a9-38e0-4f33-c910-e2cb43610837"
      },
      "execution_count": 138,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Shape of vector1: (1, 30000)\n",
            "Shape of vector2: (1, 30000)\n",
            "Shape of X_new before preprocessing: (2, 30000)\n",
            "Shape after imputation: (2, 30000)\n",
            "Shape after scaling: (2, 30000)\n",
            "Shape after PCA: (2, 100)\n",
            "Message 1:\n",
            "Predicted class: 1\n",
            "Class probabilities: [0.186 0.814]\n",
            "\n",
            "Message 2:\n",
            "Predicted class: 0\n",
            "Class probabilities: [0.75 0.25]\n",
            "\n",
            "Final shape of X_new: (2, 100)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "from collections import defaultdict\n",
        "import re\n",
        "from tabulate import tabulate\n",
        "\n",
        "# Assuming results_df is your DataFrame with all the run results\n",
        "\n",
        "def simplify_pipeline(pipeline_str):\n",
        "    # Extract the main classifier name\n",
        "    classifier = re.search(r\"(\\w+)\\(\", pipeline_str).group(1)\n",
        "    return classifier.lower()\n",
        "\n",
        "# Initialize a dictionary to store all pipeline statistics\n",
        "all_pipeline_stats = defaultdict(int)\n",
        "\n",
        "# Iterate through all runs and all evaluated pipelines\n",
        "for _, row in results_df.iterrows():\n",
        "    for pipeline_str in row['pipelines_tested']:\n",
        "        simple_pipeline = simplify_pipeline(pipeline_str)\n",
        "        all_pipeline_stats[simple_pipeline] += 1\n",
        "\n",
        "# Prepare the summary table\n",
        "summary_table = [[pipeline, count] for pipeline, count in all_pipeline_stats.items()]\n",
        "\n",
        "# Sort by count\n",
        "summary_table.sort(key=lambda x: -x[1])\n",
        "\n",
        "# Print the summary table\n",
        "print(\"\\nTop 10 Pipelines Across All Runs and Evaluations:\")\n",
        "print(tabulate(summary_table[:10], headers=['Pipeline', 'Count'], tablefmt='grid'))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 218
        },
        "id": "9qalTrUsqpVD",
        "outputId": "38d1ca00-fa5d-4cc8-bbf1-a5386be19c6b"
      },
      "execution_count": 111,
      "outputs": [
        {
          "output_type": "error",
          "ename": "NameError",
          "evalue": "name 'results_df' is not defined",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-111-f0b7f5d7c499>\u001b[0m in \u001b[0;36m<cell line: 16>\u001b[0;34m()\u001b[0m\n\u001b[1;32m     14\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     15\u001b[0m \u001b[0;31m# Iterate through all runs and all evaluated pipelines\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 16\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0m_\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrow\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mresults_df\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0miterrows\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     17\u001b[0m     \u001b[0;32mfor\u001b[0m \u001b[0mpipeline_str\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'pipelines_tested'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     18\u001b[0m         \u001b[0msimple_pipeline\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msimplify_pipeline\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpipeline_str\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mNameError\u001b[0m: name 'results_df' is not defined"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# File name to search for\n",
        "file_name = \"lab_logs_blindtest_activity_sysmon_1000samples_july_28_2024_filtered_vectors.parquet\"\n",
        "\n",
        "# Get the download URL of the specific file\n",
        "# download_url = get_specific_file_from_latest_release(github_token, repository_name, file_name)\n",
        "download_url = get_specific_file_from_tagged_release(github_token, repository_name, \"lab\", file_name)\n",
        "print(download_url)\n",
        "\n",
        "if download_url:\n",
        "    local_file_path = file_name\n",
        "    download_file(download_url, github_token, local_file_path)\n",
        "else:\n",
        "    print(\"File not found.\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 85,
          "referenced_widgets": [
            "8a807c2780cf4a65ad92dfa1ead0e439",
            "021bf8d789b74e3d899a99eeb82a0036",
            "f7aeed7c0692419591ca57bffee51739",
            "d7f2da7e3beb42dfaf31dc69eb7a597e",
            "c7b913c695fc448c8fc7b31f7098f636",
            "a59325353a1d4902b03f5a37c0293934",
            "6cd3d0fc462c4b14bbe6be92b8e6103e",
            "0cfdc6a2fa49499e9f0ce350b88dfbc4",
            "a9c70dae97424ca290a75e10d24baf52",
            "f0fc3fee01b04ffc922096ee18b6cb0f",
            "9142d6e9793648a9909e5ce3dabf415b"
          ]
        },
        "id": "SGH18PwBSdeE",
        "outputId": "6bb659aa-bdf4-49fc-ad4a-c9f8968ce3c5"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "https://api.github.com/repos/norandom/log2ml/releases/assets/182698628\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "  0%|          | 0.00/3.29M [00:00<?, ?iB/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "8a807c2780cf4a65ad92dfa1ead0e439"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "File downloaded successfully and saved as lab_logs_blindtest_activity_sysmon_1000samples_july_28_2024_filtered_vectors.parquet\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Split data\n",
        "X = np.array(df['message_vector'].tolist())\n",
        "y = df['label_encoded'].values"
      ],
      "metadata": {
        "id": "kFKHmuKeWqbM"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.preprocessing import QuantileTransformer, LabelEncoder\n",
        "from tpot import TPOTClassifier\n",
        "from sklearn.metrics import f1_score\n",
        "from collections import defaultdict\n",
        "import time\n",
        "import re\n",
        "from tabulate import tabulate\n",
        "import warnings\n",
        "warnings.filterwarnings('ignore')\n",
        "\n",
        "# Assuming X and y are already loaded\n",
        "\n",
        "# Encode labels\n",
        "le = LabelEncoder()\n",
        "y_encoded = le.fit_transform(y)\n",
        "\n",
        "# Function to perform PCA\n",
        "def perform_pca(X, transformer, n_components=0.95):\n",
        "    X_transformed = transformer.fit_transform(X)\n",
        "    from sklearn.decomposition import PCA\n",
        "    pca = PCA(n_components=n_components)\n",
        "    X_pca = pca.fit_transform(X_transformed)\n",
        "    n_components_selected = X_pca.shape[1]\n",
        "    return X_pca, n_components_selected\n",
        "\n",
        "# Perform PCA with QuantileTransformer\n",
        "transformer = QuantileTransformer(n_quantiles=1000, output_distribution='normal', random_state=42)\n",
        "X_pca, n_components = perform_pca(X, transformer)\n",
        "\n",
        "print(f\"Number of components selected to explain 95% of variance: {n_components}\")\n",
        "\n",
        "# Initialize results storage\n",
        "results = defaultdict(list)\n",
        "\n",
        "# Number of runs\n",
        "n_runs = 2\n",
        "\n",
        "# Function to extract number of features selected\n",
        "def get_n_features(pipeline_str):\n",
        "    match = re.search(r'SelectPercentile\\(score_func=f_classif, percentile=(\\d+)\\)', pipeline_str)\n",
        "    if match:\n",
        "        percentile = int(match.group(1))\n",
        "        return int(X_pca.shape[1] * percentile / 100)\n",
        "    return X_pca.shape[1]  # If no feature selection, return all features\n",
        "\n",
        "for run in range(n_runs):\n",
        "    print(f\"\\nStarting run {run + 1}/{n_runs}\")\n",
        "    start_time = time.time()\n",
        "\n",
        "    # Stratified split\n",
        "    X_train, X_test, y_train, y_test = train_test_split(X_pca, y_encoded, test_size=0.2, random_state=42 + run, stratify=y_encoded)\n",
        "\n",
        "    # TPOT classifier with Neural Network configuration\n",
        "    tpot = TPOTClassifier(\n",
        "        config_dict='TPOT NN',  # Use TPOT's built-in neural network configuration\n",
        "        scoring='f1_weighted',\n",
        "        verbosity=2,\n",
        "        generations=5,\n",
        "        population_size=20,\n",
        "        random_state=42 + run,\n",
        "        max_time_mins=10,  # Increased runtime to 10 minutes per run\n",
        "        n_jobs=-1  # Use all available CPU cores\n",
        "    )\n",
        "\n",
        "    try:\n",
        "        # Fit\n",
        "        tpot.fit(X_train, y_train)\n",
        "\n",
        "        # Predict and calculate F1 score\n",
        "        y_pred = tpot.predict(X_test)\n",
        "        f1 = f1_score(y_test, y_pred, average='weighted')\n",
        "\n",
        "        # Get pipeline string and extract number of features\n",
        "        pipeline_str = str(tpot.fitted_pipeline_)\n",
        "        n_features = get_n_features(pipeline_str)\n",
        "\n",
        "        # Store results\n",
        "        results['run'].append(run + 1)\n",
        "        results['f1_score'].append(f1)\n",
        "        results['best_pipeline'].append(pipeline_str)\n",
        "        results['n_features'].append(n_features)\n",
        "        results['runtime'].append(time.time() - start_time)\n",
        "        results['pipelines_tested'].append(len(tpot.evaluated_individuals_))\n",
        "\n",
        "        print(f\"Run {run + 1} completed. F1 Score: {f1:.4f}, Features selected: {n_features}, Pipelines tested: {len(tpot.evaluated_individuals_)}\")\n",
        "\n",
        "    except Exception as e:\n",
        "        print(f\"Error in run {run + 1}: {str(e)}\")\n",
        "        results['run'].append(run + 1)\n",
        "        results['f1_score'].append(None)\n",
        "        results['best_pipeline'].append(None)\n",
        "        results['n_features'].append(None)\n",
        "        results['runtime'].append(time.time() - start_time)\n",
        "        results['pipelines_tested'].append(None)\n",
        "\n",
        "# Convert results to DataFrame\n",
        "results_df = pd.DataFrame(results)\n",
        "\n",
        "# Print results table\n",
        "print(\"\\nResults Summary:\")\n",
        "print(tabulate(results_df, headers='keys', tablefmt='grid'))\n",
        "\n",
        "# Save results to CSV\n",
        "results_df.to_csv('tpot_nn_results.csv', index=False)\n",
        "print(\"\\nResults saved to 'tpot_nn_results.csv'\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 870,
          "referenced_widgets": [
            "2380e728c4b94d4a82d99c5df53bcfb8",
            "60e0fda3b0b64788b12de0492e48a8eb",
            "b4aab6b20b704970a6d88b4203aafe33",
            "94853d6fcd9e485ab00941270501bdc2",
            "85171f4f5f6f4cf798c8f0afc85c0f45",
            "188af8de0a894c4b862c04ae22f6e2ab",
            "cca3270cffa747b0819b1a50fff1ef02",
            "2f02cde9cf5f45fc8ce05a545baad40c",
            "aa35eac1e7964054bf8ab8903cd3e182",
            "bf41ac8c2a6f47e6b6956e4389485e3e",
            "6f7d22c33bbd434e83d5764c7ebed942",
            "612cffdae98544d480553f9a40e6bd01",
            "9eb0c8bff0b6480caac00ebc3381b0d7",
            "ef6da18b47a04feeabf4d5e1d0437f0b",
            "a992cbe30d1c47b09724593a260a690c",
            "ee97630f2ff341bfb51cedf7c99bf39c",
            "c89e1c3487e040caa253aad97f240fe7",
            "31666166fb934ef4b8d568f609db9fb3",
            "2ee32d42a6124f9fa35a04115268427d",
            "d78b5fb09a4d4aacb52940e2a12de183",
            "d8a982183d3f45d2b77dddd74f4ff9e7",
            "f679dcba359e460ebe3d763e086922c7"
          ]
        },
        "id": "iyExRJRjsDBO",
        "outputId": "dfaff146-db7c-47d5-bd93-535282346bea"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Number of components selected to explain 95% of variance: 5\n",
            "\n",
            "Starting run 1/2\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/20 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "2380e728c4b94d4a82d99c5df53bcfb8"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 2 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 3 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 4 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 5 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Best pipeline: GaussianNB(input_matrix)\n",
            "Run 1 completed. F1 Score: 0.9872, Features selected: 5, Pipelines tested: 115\n",
            "\n",
            "Starting run 2/2\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/20 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "612cffdae98544d480553f9a40e6bd01"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 2 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 3 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 4 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 5 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Best pipeline: ExtraTreesClassifier(input_matrix, bootstrap=False, criterion=entropy, max_features=0.8500000000000001, min_samples_leaf=20, min_samples_split=19, n_estimators=100)\n",
            "Run 2 completed. F1 Score: 0.9872, Features selected: 5, Pipelines tested: 114\n",
            "\n",
            "Results Summary:\n",
            "+----+-------+------------+----------------------------------------------------------------------------------+--------------+-----------+--------------------+\n",
            "|    |   run |   f1_score | best_pipeline                                                                    |   n_features |   runtime |   pipelines_tested |\n",
            "+====+=======+============+==================================================================================+==============+===========+====================+\n",
            "|  0 |     1 |   0.987198 | Pipeline(steps=[('gaussiannb', GaussianNB())])                                   |            5 |   109.885 |                115 |\n",
            "+----+-------+------------+----------------------------------------------------------------------------------+--------------+-----------+--------------------+\n",
            "|  1 |     2 |   0.987198 | Pipeline(steps=[('extratreesclassifier',                                         |            5 |   108.381 |                114 |\n",
            "|    |       |            |                  ExtraTreesClassifier(criterion='entropy',                       |              |           |                    |\n",
            "|    |       |            |                                       max_features=0.8500000000000001,           |              |           |                    |\n",
            "|    |       |            |                                       min_samples_leaf=20, min_samples_split=19, |              |           |                    |\n",
            "|    |       |            |                                       random_state=43))])                        |              |           |                    |\n",
            "+----+-------+------------+----------------------------------------------------------------------------------+--------------+-----------+--------------------+\n",
            "\n",
            "Results saved to 'tpot_nn_results.csv'\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import joblib\n",
        "import numpy as np\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.metrics import f1_score\n",
        "\n",
        "# Find the best run (highest F1 score)\n",
        "best_run_index = results_df['f1_score'].idxmax()\n",
        "best_pipeline_str = results_df.loc[best_run_index, 'best_pipeline']\n",
        "\n",
        "# Re-fit the best pipeline on the entire dataset\n",
        "X_train_full, X_test_full, y_train_full, y_test_full = train_test_split(X_pca, y_encoded, test_size=0.2, random_state=42, stratify=y_encoded)\n",
        "best_model = tpot.fitted_pipeline_\n",
        "\n",
        "# Save the model using joblib\n",
        "model_filename = 'best_tpot_nn_model.joblib'\n",
        "joblib.dump(best_model, model_filename)\n",
        "\n",
        "print(f\"\\nBest model exported as joblib: {model_filename}\")\n",
        "\n",
        "# You can also save the best pipeline as a Python script\n",
        "python_filename = 'best_tpot_nn_pipeline.py'\n",
        "best_pipeline_script = tpot.export(python_filename)\n",
        "\n",
        "print(f\"Best pipeline saved as Python script: {python_filename}\")\n",
        "\n",
        "# Print the best pipeline\n",
        "print(f\"\\nBest Pipeline:\\n{best_pipeline_str}\")\n",
        "\n",
        "# Verify the saved model\n",
        "try:\n",
        "    loaded_model = joblib.load(model_filename)\n",
        "    y_pred = loaded_model.predict(X_test_full)\n",
        "    f1 = f1_score(y_test_full, y_pred, average='weighted')\n",
        "    print(f\"\\nLoaded model verified. F1 Score: {f1:.4f}\")\n",
        "except Exception as e:\n",
        "    print(f\"\\nError verifying saved model: {str(e)}\")\n",
        "\n",
        "# Print information about how to use the saved model\n",
        "print(\"\\nTo use the saved model in the future:\")\n",
        "print(\"1. Load the model: loaded_model = joblib.load('best_tpot_nn_model.joblib')\")\n",
        "print(\"2. Make predictions: predictions = loaded_model.predict(X)\")\n",
        "print(\"Note: Make sure to preprocess your input data (X) the same way as during training.\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "tQ06A8TMgdKw",
        "outputId": "8e9cbfe1-8098-437a-c184-9172d0284db7"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Best model exported as joblib: best_tpot_nn_model.joblib\n",
            "Best pipeline saved as Python script: best_tpot_nn_pipeline.py\n",
            "\n",
            "Best Pipeline:\n",
            "Pipeline(steps=[('gaussiannb', GaussianNB())])\n",
            "\n",
            "Loaded model verified. F1 Score: 0.9988\n",
            "\n",
            "To use the saved model in the future:\n",
            "1. Load the model: loaded_model = joblib.load('best_tpot_nn_model.joblib')\n",
            "2. Make predictions: predictions = loaded_model.predict(X)\n",
            "Note: Make sure to preprocess your input data (X) the same way as during training.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "from collections import defaultdict\n",
        "from tabulate import tabulate\n",
        "\n",
        "# Assuming results_df is already loaded or created from the previous step\n",
        "\n",
        "# Define the classifiers available in TPOT NN configuration\n",
        "tpot_nn_classifiers = [\n",
        "    'MLPClassifier',\n",
        "    'KNeighborsClassifier',\n",
        "    'XGBClassifier',\n",
        "    'LinearSVC',\n",
        "    'SGDClassifier'\n",
        "]\n",
        "\n",
        "# Initialize a dictionary to store algorithm statistics\n",
        "algorithm_stats = defaultdict(int)\n",
        "\n",
        "# Total number of pipelines tested\n",
        "total_pipelines = 0\n",
        "\n",
        "# Iterate through all runs\n",
        "for _, row in results_df.iterrows():\n",
        "    pipelines_tested = row['pipelines_tested']\n",
        "    total_pipelines += pipelines_tested\n",
        "\n",
        "    # Distribute the pipelines tested equally among all classifiers\n",
        "    # This is an approximation, as we don't have the exact breakdown\n",
        "    for classifier in tpot_nn_classifiers:\n",
        "        algorithm_stats[classifier] += pipelines_tested // len(tpot_nn_classifiers)\n",
        "\n",
        "    # Add the remainder to 'Other' category\n",
        "    algorithm_stats['Other'] += pipelines_tested % len(tpot_nn_classifiers)\n",
        "\n",
        "# Add the best pipelines to their respective categories\n",
        "for _, row in results_df.iterrows():\n",
        "    best_pipeline = row['best_pipeline']\n",
        "    for classifier in tpot_nn_classifiers:\n",
        "        if classifier in best_pipeline:\n",
        "            algorithm_stats[classifier] += 1\n",
        "            break\n",
        "    else:\n",
        "        algorithm_stats['Other'] += 1\n",
        "\n",
        "# Prepare the summary table\n",
        "summary_table = [[algorithm, count] for algorithm, count in algorithm_stats.items() if count > 0]\n",
        "\n",
        "# Sort by count\n",
        "summary_table.sort(key=lambda x: -x[1])\n",
        "\n",
        "# Print the summary table\n",
        "print(\"\\nEstimated Algorithms Used Across All Runs:\")\n",
        "print(tabulate(summary_table, headers=['Algorithm', 'Estimated Count'], tablefmt='grid'))\n",
        "\n",
        "# Calculate and print additional statistics\n",
        "total_runs = len(results_df)\n",
        "successful_runs = results_df['f1_score'].notna().sum()\n",
        "average_f1 = results_df['f1_score'].mean()\n",
        "average_features = results_df['n_features'].mean() if 'n_features' in results_df.columns else None\n",
        "average_runtime = results_df['runtime'].mean()\n",
        "\n",
        "print(f\"\\nTotal Runs: {total_runs}\")\n",
        "print(f\"Successful Runs: {successful_runs}\")\n",
        "print(f\"Average F1 Score: {average_f1:.4f}\")\n",
        "if average_features is not None:\n",
        "    print(f\"Average Number of Features: {average_features:.2f}\")\n",
        "print(f\"Average Runtime: {average_runtime:.2f} seconds\")\n",
        "print(f\"Total Pipelines Tested: {total_pipelines}\")\n",
        "\n",
        "# Print full best pipelines for each run\n",
        "print(\"\\nBest Pipelines for Each Run:\")\n",
        "for index, row in results_df.iterrows():\n",
        "    print(f\"\\nRun {index + 1}:\")\n",
        "    print(f\"F1 Score: {row['f1_score']:.4f}\")\n",
        "    print(f\"Pipeline: {row['best_pipeline']}\")\n",
        "    print(f\"Pipelines tested in this run: {row['pipelines_tested']}\")\n",
        "\n",
        "# Optional: Add visualization\n",
        "import matplotlib.pyplot as plt\n",
        "\n",
        "# Visualize F1 scores across runs\n",
        "plt.figure(figsize=(10, 6))\n",
        "plt.plot(results_df['run'], results_df['f1_score'], marker='o')\n",
        "plt.title('F1 Score Across Runs')\n",
        "plt.xlabel('Run')\n",
        "plt.ylabel('F1 Score')\n",
        "plt.grid(True)\n",
        "plt.savefig('f1_scores_across_runs.png')\n",
        "plt.close()\n",
        "\n",
        "# Visualize pipeline counts\n",
        "algorithms, counts = zip(*summary_table)\n",
        "plt.figure(figsize=(12, 6))\n",
        "plt.bar(algorithms, counts)\n",
        "plt.title('Estimated Algorithm Usage')\n",
        "plt.xlabel('Algorithm')\n",
        "plt.ylabel('Estimated Count')\n",
        "plt.xticks(rotation=45, ha='right')\n",
        "plt.tight_layout()\n",
        "plt.savefig('estimated_algorithm_usage.png')\n",
        "plt.close()\n",
        "\n",
        "print(\"\\nVisualization plots saved as 'f1_scores_across_runs.png' and 'estimated_algorithm_usage.png'\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "5m0mtcVZduol",
        "outputId": "1d8b8679-4cbc-4574-dc35-6e7ab8b3d1cd"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Estimated Algorithms Used Across All Runs:\n",
            "+----------------------+-------------------+\n",
            "| Algorithm            |   Estimated Count |\n",
            "+======================+===================+\n",
            "| MLPClassifier        |                45 |\n",
            "+----------------------+-------------------+\n",
            "| KNeighborsClassifier |                45 |\n",
            "+----------------------+-------------------+\n",
            "| XGBClassifier        |                45 |\n",
            "+----------------------+-------------------+\n",
            "| LinearSVC            |                45 |\n",
            "+----------------------+-------------------+\n",
            "| SGDClassifier        |                45 |\n",
            "+----------------------+-------------------+\n",
            "| Other                |                 6 |\n",
            "+----------------------+-------------------+\n",
            "\n",
            "Total Runs: 2\n",
            "Successful Runs: 2\n",
            "Average F1 Score: 0.9872\n",
            "Average Number of Features: 5.00\n",
            "Average Runtime: 109.13 seconds\n",
            "Total Pipelines Tested: 229\n",
            "\n",
            "Best Pipelines for Each Run:\n",
            "\n",
            "Run 1:\n",
            "F1 Score: 0.9872\n",
            "Pipeline: Pipeline(steps=[('gaussiannb', GaussianNB())])\n",
            "Pipelines tested in this run: 115\n",
            "\n",
            "Run 2:\n",
            "F1 Score: 0.9872\n",
            "Pipeline: Pipeline(steps=[('extratreesclassifier',\n",
            "                 ExtraTreesClassifier(criterion='entropy',\n",
            "                                      max_features=0.8500000000000001,\n",
            "                                      min_samples_leaf=20, min_samples_split=19,\n",
            "                                      random_state=43))])\n",
            "Pipelines tested in this run: 114\n",
            "\n",
            "Visualization plots saved as 'f1_scores_across_runs.png' and 'estimated_algorithm_usage.png'\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import matplotlib.pyplot as plt\n",
        "import pandas as pd\n",
        "\n",
        "# Assuming results_df is your DataFrame with the results\n",
        "\n",
        "fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(10, 18))\n",
        "\n",
        "ax1.plot(results_df['run'], results_df['f1_score'], 'bo-')\n",
        "ax1.set_title('TPOT-NN Performance (F1 Score) Across Runs')\n",
        "ax1.set_xlabel('Run')\n",
        "ax1.set_ylabel('F1 Score')\n",
        "ax1.grid(True)\n",
        "\n",
        "ax2.plot(results_df['run'], results_df['n_features'], 'ro-')\n",
        "ax2.set_title('Number of Features Selected Across Runs')\n",
        "ax2.set_xlabel('Run')\n",
        "ax2.set_ylabel('Number of Features')\n",
        "ax2.grid(True)\n",
        "\n",
        "ax3.plot(results_df['run'], results_df['pipelines_tested'], 'go-')\n",
        "ax3.set_title('Number of Pipelines Tested Across Runs')\n",
        "ax3.set_xlabel('Run')\n",
        "ax3.set_ylabel('Number of Pipelines')\n",
        "ax3.grid(True)\n",
        "\n",
        "plt.tight_layout()\n",
        "plt.savefig('tpot_nn_performance_features_pipelines.png')\n",
        "plt.show()\n",
        "\n",
        "# Print summary statistics\n",
        "print(\"\\nSummary Statistics:\")\n",
        "print(results_df.describe())\n",
        "\n",
        "# Optional: If you want to see the correlation between different metrics\n",
        "correlation_matrix = results_df[['f1_score', 'n_features', 'pipelines_tested', 'runtime']].corr()\n",
        "print(\"\\nCorrelation Matrix:\")\n",
        "print(correlation_matrix)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "3lBpziEae4sf",
        "outputId": "08837957-1ab6-4acb-ab65-b0f0fca2b56c"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 1000x1800 with 3 Axes>"
            ],
            "image/png": "[encoded data, 103092 characters]\n"
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Summary Statistics:\n",
            "            run  f1_score  n_features     runtime  pipelines_tested\n",
            "count  2.000000  2.000000         2.0    2.000000          2.000000\n",
            "mean   1.500000  0.987198         5.0  109.132951        114.500000\n",
            "std    0.707107  0.000000         0.0    1.063263          0.707107\n",
            "min    1.000000  0.987198         5.0  108.381110        114.000000\n",
            "25%    1.250000  0.987198         5.0  108.757030        114.250000\n",
            "50%    1.500000  0.987198         5.0  109.132951        114.500000\n",
            "75%    1.750000  0.987198         5.0  109.508871        114.750000\n",
            "max    2.000000  0.987198         5.0  109.884791        115.000000\n",
            "\n",
            "Correlation Matrix:\n",
            "                  f1_score  n_features  pipelines_tested  runtime\n",
            "f1_score               NaN         NaN               NaN      NaN\n",
            "n_features             NaN         NaN               NaN      NaN\n",
            "pipelines_tested       NaN         NaN               1.0      1.0\n",
            "runtime                NaN         NaN               1.0      1.0\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Different Algorithm set"
      ],
      "metadata": {
        "id": "QJQXi06FdUDN"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "from sklearn.decomposition import PCA\n",
        "from sklearn.preprocessing import QuantileTransformer, LabelEncoder\n",
        "from sklearn.model_selection import train_test_split\n",
        "from tpot import TPOTClassifier\n",
        "from sklearn.metrics import f1_score\n",
        "from collections import defaultdict\n",
        "import time\n",
        "import re\n",
        "from tabulate import tabulate\n",
        "\n",
        "\n",
        "\n",
        "# Encode labels\n",
        "le = LabelEncoder()\n",
        "y_encoded = le.fit_transform(y)\n",
        "\n",
        "# Function to perform PCA\n",
        "def perform_pca(X, transformer, n_components=0.95):\n",
        "    X_transformed = transformer.fit_transform(X)\n",
        "    pca = PCA(n_components=n_components)\n",
        "    X_pca = pca.fit_transform(X_transformed)\n",
        "    n_components_selected = X_pca.shape[1]\n",
        "    return X_pca, n_components_selected\n",
        "\n",
        "# Perform PCA with QuantileTransformer\n",
        "transformer = QuantileTransformer(n_quantiles=1000, output_distribution='normal', random_state=42)\n",
        "X_pca, n_components = perform_pca(X, transformer)\n",
        "\n",
        "print(f\"Number of components selected to explain 95% of variance: {n_components}\")\n",
        "\n",
        "# Initialize results storage\n",
        "results = defaultdict(list)\n",
        "\n",
        "# Number of runs\n",
        "n_runs = 2\n",
        "\n",
        "# Function to extract number of features selected\n",
        "def get_n_features(pipeline_str):\n",
        "    match = re.search(r'SelectPercentile\\(score_func=f_classif, percentile=(\\d+)\\)', pipeline_str)\n",
        "    if match:\n",
        "        percentile = int(match.group(1))\n",
        "        return int(X_pca.shape[1] * percentile / 100)\n",
        "    return X_pca.shape[1]  # If no feature selection, return all features\n",
        "\n",
        "for run in range(n_runs):\n",
        "    print(f\"\\nStarting run {run + 1}/{n_runs}\")\n",
        "    start_time = time.time()\n",
        "\n",
        "    # Stratified split\n",
        "    X_train, X_test, y_train, y_test = train_test_split(X_pca, y_encoded, test_size=0.2, random_state=42 + run, stratify=y_encoded)\n",
        "\n",
        "    # TPOT classifier with reduced complexity and CPU usage\n",
        "    tpot = TPOTClassifier(\n",
        "        config_dict='TPOT light',  # Use a lighter configuration\n",
        "        scoring='f1_weighted',\n",
        "        verbosity=2,\n",
        "        generations=3,\n",
        "        population_size=10,\n",
        "        n_jobs=-1,\n",
        "        random_state=42 + run\n",
        "    )\n",
        "\n",
        "    try:\n",
        "        # Fit\n",
        "        tpot.fit(X_train, y_train)\n",
        "\n",
        "        # Predict and calculate F1 score\n",
        "        y_pred = tpot.predict(X_test)\n",
        "        f1 = f1_score(y_test, y_pred, average='weighted')\n",
        "\n",
        "        # Get pipeline string and extract number of features\n",
        "        pipeline_str = str(tpot.fitted_pipeline_)\n",
        "        n_features = get_n_features(pipeline_str)\n",
        "\n",
        "        # Store results\n",
        "        results['run'].append(run + 1)\n",
        "        results['f1_score'].append(f1)\n",
        "        results['best_pipeline'].append(pipeline_str)\n",
        "        results['n_features'].append(n_features)\n",
        "        results['runtime'].append(time.time() - start_time)\n",
        "        results['pipelines_tested'].append(len(tpot.evaluated_individuals_))\n",
        "\n",
        "        print(f\"Run {run + 1} completed. F1 Score: {f1:.4f}, Features selected: {n_features}, Pipelines tested: {len(tpot.evaluated_individuals_)}\")\n",
        "\n",
        "    except Exception as e:\n",
        "        print(f\"Error in run {run + 1}: {str(e)}\")\n",
        "        results['run'].append(run + 1)\n",
        "        results['f1_score'].append(None)\n",
        "        results['best_pipeline'].append(None)\n",
        "        results['n_features'].append(None)\n",
        "        results['runtime'].append(time.time() - start_time)\n",
        "        results['pipelines_tested'].append(None)\n",
        "\n",
        "# Print results table\n",
        "print(\"\\nResults Summary:\")\n",
        "print(tabulate(results, headers='keys', tablefmt='grid'))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 669,
          "referenced_widgets": [
            "e329ae9f00ae426caba593bf82062720",
            "6b18e9941ad8489a856d8951086dc0ec",
            "bd1ef0b1216f44e981e06617353af203",
            "cb16a7ccc2d048699ec81bd9cc08782b",
            "2057161353254330b31e15c030f5c77e",
            "2768fc55816a4ddabd3389b3e6c9a0df",
            "12c31e7d69934b1bb13b7e4de18f9aee",
            "d3f693b6862747fbab9f786e7ef0a9cf",
            "f3a099a3356044e7a641d590c6381041",
            "aab64f46dfdf4948bec48ef02618cf75",
            "b83434e8778040d4975f5fab89a976ec",
            "3ae62907413b4d969f53c4a3092fb46d",
            "5af08e85e25040b19544493df13617d5",
            "439b9e942cec4fe699f3e561082585b5",
            "b4b43f188f454890a04bc1869680c46d",
            "4de8382a838648b6bf2d639b5ae65c7b",
            "32aa5ea1c8354c0eb3538819a48e81ea",
            "ed0c20dcb4764e629766a2e31d019edf",
            "90db1881f3254f71adf5d809c0d83bae",
            "87b95caad65649a9b85bdc015c665838",
            "8151a7980fc346debb0caf1c20af5429",
            "2f6c4ac937de426ab94fdde3fc4fc95a"
          ]
        },
        "id": "pDB9efndcv9g",
        "outputId": "922183ba-2287-40a7-8d73-32a476c0557f"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Number of components selected to explain 95% of variance: 5\n",
            "\n",
            "Starting run 1/2\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/40 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "e329ae9f00ae426caba593bf82062720"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 2 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 3 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Best pipeline: KNeighborsClassifier(input_matrix, n_neighbors=21, p=1, weights=distance)\n",
            "Run 1 completed. F1 Score: 0.9872, Features selected: 5, Pipelines tested: 39\n",
            "\n",
            "Starting run 2/2\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Optimization Progress:   0%|          | 0/40 [00:00<?, ?pipeline/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "3ae62907413b4d969f53c4a3092fb46d"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Generation 1 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 2 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Generation 3 - Current best internal CV score: 0.9873368055887921\n",
            "\n",
            "Best pipeline: KNeighborsClassifier(input_matrix, n_neighbors=86, p=1, weights=distance)\n",
            "Run 2 completed. F1 Score: 0.9872, Features selected: 5, Pipelines tested: 38\n",
            "\n",
            "Results Summary:\n",
            "+-------+------------+--------------------------------------------------------------+--------------+-----------+--------------------+\n",
            "|   run |   f1_score | best_pipeline                                                |   n_features |   runtime |   pipelines_tested |\n",
            "+=======+============+==============================================================+==============+===========+====================+\n",
            "|     1 |   0.987198 | Pipeline(steps=[('kneighborsclassifier',                     |            5 |   9.23632 |                 39 |\n",
            "|       |            |                  KNeighborsClassifier(n_neighbors=21, p=1,   |              |           |                    |\n",
            "|       |            |                                       weights='distance'))]) |              |           |                    |\n",
            "+-------+------------+--------------------------------------------------------------+--------------+-----------+--------------------+\n",
            "|     2 |   0.987198 | Pipeline(steps=[('kneighborsclassifier',                     |            5 |   4.89899 |                 38 |\n",
            "|       |            |                  KNeighborsClassifier(n_neighbors=86, p=1,   |              |           |                    |\n",
            "|       |            |                                       weights='distance'))]) |              |           |                    |\n",
            "+-------+------------+--------------------------------------------------------------+--------------+-----------+--------------------+\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "from collections import defaultdict\n",
        "from tabulate import tabulate\n",
        "\n",
        "# Assuming results_df is already loaded or created from the previous step\n",
        "\n",
        "# Define the classifiers available in TPOT-NN configuration\n",
        "tpot_nn_classifiers = [\n",
        "    'LogisticRegression',\n",
        "    'KNeighborsClassifier',\n",
        "    'DecisionTreeClassifier',\n",
        "    'RandomForestClassifier',\n",
        "    'GradientBoostingClassifier',\n",
        "    'MLPClassifier'\n",
        "]\n",
        "\n",
        "# Initialize a dictionary to store algorithm statistics\n",
        "algorithm_stats = defaultdict(int)\n",
        "\n",
        "# Total number of pipelines tested\n",
        "total_pipelines = 0\n",
        "\n",
        "# Iterate through all runs\n",
        "for _, row in results_df.iterrows():\n",
        "    pipelines_tested = row['pipelines_tested']\n",
        "    total_pipelines += pipelines_tested\n",
        "\n",
        "    # Distribute the pipelines tested equally among all classifiers\n",
        "    # This is an approximation, as we don't have the exact breakdown\n",
        "    for classifier in tpot_nn_classifiers:\n",
        "        algorithm_stats[classifier] += pipelines_tested // len(tpot_nn_classifiers)\n",
        "\n",
        "    # Add the remainder to 'Other' category\n",
        "    algorithm_stats['Other'] += pipelines_tested % len(tpot_nn_classifiers)\n",
        "\n",
        "# Add the best pipelines to their respective categories\n",
        "for _, row in results_df.iterrows():\n",
        "    best_pipeline = row['best_pipeline']\n",
        "    for classifier in tpot_nn_classifiers:\n",
        "        if classifier in best_pipeline:\n",
        "            algorithm_stats[classifier] += 1\n",
        "            break\n",
        "    else:\n",
        "        algorithm_stats['Other'] += 1\n",
        "\n",
        "# Prepare the summary table\n",
        "summary_table = [[algorithm, count] for algorithm, count in algorithm_stats.items() if count > 0]\n",
        "\n",
        "# Sort by count\n",
        "summary_table.sort(key=lambda x: -x[1])\n",
        "\n",
        "# Print the summary table\n",
        "print(\"\\nEstimated Algorithms Used Across All Runs:\")\n",
        "print(tabulate(summary_table, headers=['Algorithm', 'Estimated Count'], tablefmt='grid'))\n",
        "\n",
        "# Calculate and print additional statistics\n",
        "total_runs = len(results_df)\n",
        "successful_runs = results_df['f1_score'].notna().sum()\n",
        "average_f1 = results_df['f1_score'].mean()\n",
        "average_features = results_df['n_features'].mean()\n",
        "average_runtime = results_df['runtime'].mean()\n",
        "\n",
        "print(f\"\\nTotal Runs: {total_runs}\")\n",
        "print(f\"Successful Runs: {successful_runs}\")\n",
        "print(f\"Average F1 Score: {average_f1:.4f}\")\n",
        "print(f\"Average Number of Features: {average_features:.2f}\")\n",
        "print(f\"Average Runtime: {average_runtime:.2f} seconds\")\n",
        "print(f\"Total Pipelines Tested: {total_pipelines}\")\n",
        "\n",
        "# Print full best pipelines for each run\n",
        "print(\"\\nBest Pipelines for Each Run:\")\n",
        "for index, row in results_df.iterrows():\n",
        "    print(f\"\\nRun {index + 1}:\")\n",
        "    print(f\"F1 Score: {row['f1_score']:.4f}\")\n",
        "    print(f\"Pipeline: {row['best_pipeline']}\")\n",
        "    print(f\"Pipelines tested in this run: {row['pipelines_tested']}\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "VgKt6AU28-6f",
        "outputId": "ab7671a3-1229-42f5-807a-eec12327733a"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Estimated Algorithms Used Across All Runs:\n",
            "+----------------------------+-------------------+\n",
            "| Algorithm                  |   Estimated Count |\n",
            "+============================+===================+\n",
            "| LogisticRegression         |                38 |\n",
            "+----------------------------+-------------------+\n",
            "| KNeighborsClassifier       |                38 |\n",
            "+----------------------------+-------------------+\n",
            "| DecisionTreeClassifier     |                38 |\n",
            "+----------------------------+-------------------+\n",
            "| RandomForestClassifier     |                38 |\n",
            "+----------------------------+-------------------+\n",
            "| GradientBoostingClassifier |                38 |\n",
            "+----------------------------+-------------------+\n",
            "| MLPClassifier              |                38 |\n",
            "+----------------------------+-------------------+\n",
            "| Other                      |                 3 |\n",
            "+----------------------------+-------------------+\n",
            "\n",
            "Total Runs: 2\n",
            "Successful Runs: 2\n",
            "Average F1 Score: 0.9872\n",
            "Average Number of Features: 5.00\n",
            "Average Runtime: 109.13 seconds\n",
            "Total Pipelines Tested: 229\n",
            "\n",
            "Best Pipelines for Each Run:\n",
            "\n",
            "Run 1:\n",
            "F1 Score: 0.9872\n",
            "Pipeline: Pipeline(steps=[('gaussiannb', GaussianNB())])\n",
            "Pipelines tested in this run: 115\n",
            "\n",
            "Run 2:\n",
            "F1 Score: 0.9872\n",
            "Pipeline: Pipeline(steps=[('extratreesclassifier',\n",
            "                 ExtraTreesClassifier(criterion='entropy',\n",
            "                                      max_features=0.8500000000000001,\n",
            "                                      min_samples_leaf=20, min_samples_split=19,\n",
            "                                      random_state=43))])\n",
            "Pipelines tested in this run: 114\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import matplotlib.pyplot as plt\n",
        "import pandas as pd\n",
        "\n",
        "# Assuming results_df is your DataFrame with the results\n",
        "\n",
        "fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(10, 18))\n",
        "\n",
        "ax1.plot(results_df['run'], results_df['f1_score'], 'bo-')\n",
        "ax1.set_title('TPOT-NN Performance (F1 Score) Across Runs')\n",
        "ax1.set_xlabel('Run')\n",
        "ax1.set_ylabel('F1 Score')\n",
        "ax1.grid(True)\n",
        "\n",
        "ax2.plot(results_df['run'], results_df['n_features'], 'ro-')\n",
        "ax2.set_title('Number of Features Selected Across Runs')\n",
        "ax2.set_xlabel('Run')\n",
        "ax2.set_ylabel('Number of Features')\n",
        "ax2.grid(True)\n",
        "\n",
        "ax3.plot(results_df['run'], results_df['pipelines_tested'], 'go-')\n",
        "ax3.set_title('Number of Pipelines Tested Across Runs')\n",
        "ax3.set_xlabel('Run')\n",
        "ax3.set_ylabel('Number of Pipelines')\n",
        "ax3.grid(True)\n",
        "\n",
        "plt.tight_layout()\n",
        "plt.savefig('tpot_nn_performance_features_pipelines.png')\n",
        "plt.show()\n",
        "\n",
        "# Print summary statistics\n",
        "print(\"\\nSummary Statistics:\")\n",
        "print(results_df.describe())\n",
        "\n",
        "# Optional: If you want to see the correlation between different metrics\n",
        "correlation_matrix = results_df[['f1_score', 'n_features', 'pipelines_tested', 'runtime']].corr()\n",
        "print(\"\\nCorrelation Matrix:\")\n",
        "print(correlation_matrix)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "SYRHdR4_YKXA",
        "outputId": "a25b02c4-ae41-4ef9-c701-a77d227b7ab9"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 1000x1800 with 3 Axes>"
            ],
            "image/png": "[encoded data, 103092 characters]\n"
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "Summary Statistics:\n",
            "            run  f1_score  n_features     runtime  pipelines_tested\n",
            "count  2.000000  2.000000         2.0    2.000000          2.000000\n",
            "mean   1.500000  0.987198         5.0  109.132951        114.500000\n",
            "std    0.707107  0.000000         0.0    1.063263          0.707107\n",
            "min    1.000000  0.987198         5.0  108.381110        114.000000\n",
            "25%    1.250000  0.987198         5.0  108.757030        114.250000\n",
            "50%    1.500000  0.987198         5.0  109.132951        114.500000\n",
            "75%    1.750000  0.987198         5.0  109.508871        114.750000\n",
            "max    2.000000  0.987198         5.0  109.884791        115.000000\n",
            "\n",
            "Correlation Matrix:\n",
            "                  f1_score  n_features  pipelines_tested  runtime\n",
            "f1_score               NaN         NaN               NaN      NaN\n",
            "n_features             NaN         NaN               NaN      NaN\n",
            "pipelines_tested       NaN         NaN               1.0      1.0\n",
            "runtime                NaN         NaN               1.0      1.0\n"
          ]
        }
      ]
    }
  ]
}