{"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.13"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":116062,"databundleVersionId":14084779,"sourceType":"competition"},{"sourceId":13717938,"sourceType":"datasetVersion","datasetId":8727420}],"dockerImageVersionId":31153,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false},"papermill":{"default_parameters":{},"duration":6769.708381,"end_time":"2025-10-16T13:10:17.559883","environment_variables":{},"exception":null,"input_path":"__notebook__.ipynb","output_path":"__notebook__.ipynb","parameters":{},"start_time":"2025-10-16T11:17:27.851502","version":"2.6.0"},"widgets":{"application/vnd.jupyter.widget-state+json":{"state":{"01fc0038d9bc4e8b9b40f4cabbbe6419":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"068d4cb0ff08436e8f5fc3def5bbecb4":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"0faac9bd4b3d499bb8139d97bd94c054":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_5edca90c211f43f2b55bcf8bb9adb498","placeholder":"​","style":"IPY_MODEL_fe1abcc2709345a592937e73bc223b58","tabbable":null,"tooltip":null,"value":"Predicting on Test Set: 100%"}},"154ba6fa8e9e4671b8ef4ef78f3cab74":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_e285e1fe413c4ec8b98a57d686604523","placeholder":"​","style":"IPY_MODEL_76694b9df88b408db06b45e0481284b5","tabbable":null,"tooltip":null,"value":"Parsing train_sequences.fasta: "}},"190cb21517d34bd4969e265ef8cb7fcc":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":"20px"}},"1ddb219d6e5a4f759925ac3722498b37":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"20aefbfb0d1f4f598fe66764fb25ac25":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"2ca45dbb86b94f579094f2bad22333ca":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"2d98a050db934565bf08f88bb5eca425":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"2f616072e455432dbe810287e109b233":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"36d3b5e2ae114679a824d9008c6a4f52":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":"20px"}},"3c8d8043277249b29cc08202f7e9c44a":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_f9fafe80c406468da52bcd3c595f3b81","placeholder":"​","style":"IPY_MODEL_85c0e30d0a4849e4a0303639b85d7629","tabbable":null,"tooltip":null,"value":"Parsing testsuperset.fasta: "}},"42b4f5ecdc764112828a865a79a4f942":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"43a813f4463f47a8b944a83fc4a46c16":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"4f5c645437ce4989832b817eb5d63851":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"501478b72d7b4fa6bbe5ced3af2e1af8":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"54e9071c002a4e8c9afdfccf9dff31e1":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_99a1fd7525444ff5a16544e9b1c9b901","max":82404,"min":0,"orientation":"horizontal","style":"IPY_MODEL_8861c566477f486cb2eaf52a662f7249","tabbable":null,"tooltip":null,"value":82404}},"5edca90c211f43f2b55bcf8bb9adb498":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"5f96ab84c4d4442788461e6ceaa11e25":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"611e184c53f946c09f72833da96f0edc":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_068d4cb0ff08436e8f5fc3def5bbecb4","placeholder":"​","style":"IPY_MODEL_fca78ac627094f999f0c245c8eddd8c0","tabbable":null,"tooltip":null,"value":"Processing Train Sequences: 100%"}},"64e78dcff78b4ddfa840c87038c02f8e":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_501478b72d7b4fa6bbe5ced3af2e1af8","placeholder":"​","style":"IPY_MODEL_903f4606fb6246fea3b57acd53c8936f","tabbable":null,"tooltip":null,"value":" 224309/? [00:02&lt;00:00, 134638.27it/s]"}},"66aa4c7478434451bf45c8b16974c3d9":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"68996c0d79d245759799d0daf3178c96":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"698ce913a7cb477da42f763842d0d842":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_36d3b5e2ae114679a824d9008c6a4f52","max":1,"min":0,"orientation":"horizontal","style":"IPY_MODEL_20aefbfb0d1f4f598fe66764fb25ac25","tabbable":null,"tooltip":null,"value":1}},"76694b9df88b408db06b45e0481284b5":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"7e8700fc036a4f7294b3c0c85ed449a6":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_66aa4c7478434451bf45c8b16974c3d9","placeholder":"​","style":"IPY_MODEL_2ca45dbb86b94f579094f2bad22333ca","tabbable":null,"tooltip":null,"value":" 45/45 [14:13&lt;00:00, 17.28s/it]"}},"82f4cd2f71fe45209e1f5ed1ec19b2da":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_2d98a050db934565bf08f88bb5eca425","max":45,"min":0,"orientation":"horizontal","style":"IPY_MODEL_43a813f4463f47a8b944a83fc4a46c16","tabbable":null,"tooltip":null,"value":45}},"85c0e30d0a4849e4a0303639b85d7629":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"8861c566477f486cb2eaf52a662f7249":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"89d9490fc0d14d64bee71b083356d735":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_0faac9bd4b3d499bb8139d97bd94c054","IPY_MODEL_82f4cd2f71fe45209e1f5ed1ec19b2da","IPY_MODEL_7e8700fc036a4f7294b3c0c85ed449a6"],"layout":"IPY_MODEL_c9448159e82444a797cf126599822186","tabbable":null,"tooltip":null}},"903f4606fb6246fea3b57acd53c8936f":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"934871744c654db9ad62c57d1d59d94a":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_ca9ae4aee9c84126977252fbdf0080a7","placeholder":"​","style":"IPY_MODEL_01fc0038d9bc4e8b9b40f4cabbbe6419","tabbable":null,"tooltip":null,"value":" 82404/82404 [00:41&lt;00:00, 3299.06it/s]"}},"99a1fd7525444ff5a16544e9b1c9b901":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ac2d0c5ac1a24f8faa97b73884ff019e":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_190cb21517d34bd4969e265ef8cb7fcc","max":1,"min":0,"orientation":"horizontal","style":"IPY_MODEL_2f616072e455432dbe810287e109b233","tabbable":null,"tooltip":null,"value":1}},"ad7cfe2313d94eacae3b02290b18d20b":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_3c8d8043277249b29cc08202f7e9c44a","IPY_MODEL_698ce913a7cb477da42f763842d0d842","IPY_MODEL_64e78dcff78b4ddfa840c87038c02f8e"],"layout":"IPY_MODEL_68996c0d79d245759799d0daf3178c96","tabbable":null,"tooltip":null}},"bdc4687bb3cf45cb8eade0aa1e80332d":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_154ba6fa8e9e4671b8ef4ef78f3cab74","IPY_MODEL_ac2d0c5ac1a24f8faa97b73884ff019e","IPY_MODEL_e6288acab8cf4b91b585eaae0a74d856"],"layout":"IPY_MODEL_42b4f5ecdc764112828a865a79a4f942","tabbable":null,"tooltip":null}},"c9448159e82444a797cf126599822186":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ca9ae4aee9c84126977252fbdf0080a7":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"e285e1fe413c4ec8b98a57d686604523":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"e6288acab8cf4b91b585eaae0a74d856":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_4f5c645437ce4989832b817eb5d63851","placeholder":"​","style":"IPY_MODEL_5f96ab84c4d4442788461e6ceaa11e25","tabbable":null,"tooltip":null,"value":" 82404/? [00:01&lt;00:00, 68977.76it/s]"}},"f9fafe80c406468da52bcd3c595f3b81":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":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,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"fca78ac627094f999f0c245c8eddd8c0":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"fd82745e52d3464abed72d58c54929c7":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_611e184c53f946c09f72833da96f0edc","IPY_MODEL_54e9071c002a4e8c9afdfccf9dff31e1","IPY_MODEL_934871744c654db9ad62c57d1d59d94a"],"layout":"IPY_MODEL_1ddb219d6e5a4f759925ac3722498b37","tabbable":null,"tooltip":null}},"fe1abcc2709345a592937e73bc223b58":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}}},"version_major":2,"version_minor":0}}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"<div style=\"background: linear-gradient(135deg, #2c003e 0%, #512b58 100%); padding: 2.5rem; border-radius: 1rem; text-align: center; margin-bottom: 2rem; box-shadow: 0 4px 12px rgba(0,0,0,0.7);\">\n  <h1 style=\"color: #fe346e; margin-bottom: 0.5rem; font-weight: 700;\">Ozan MÖHÜRCÜ</h1>\n  <h2 style=\"color: #f6f5f5; font-weight: 400; font-size: 1.25rem; margin-top: 0; margin-bottom: 1.75rem;\">Data Analyst | Data Scientist</h2>\n  <div style=\"text-align: center;\">\n    <span style=\"display: inline-block; margin: 0 5px;\">\n      <a href=\"https://www.linkedin.com/in/ozanmhrc/\" target=\"_blank\" rel=\"noopener noreferrer\">\n        <img src=\"https://img.shields.io/badge/LinkedIn-0A66C2?style=for-the-badge&logo=linkedin&logoColor=white\" alt=\"LinkedIn\">\n      </a>\n    </span>\n    <span style=\"display: inline-block; margin: 0 5px;\">\n      <a href=\"https://github.com/Ozan-Mohurcu\" target=\"_blank\" rel=\"noopener noreferrer\">\n        <img src=\"https://img.shields.io/badge/GitHub-161b22?style=for-the-badge&logo=github&logoColor=white\" alt=\"GitHub\">\n      </a>\n    </span>\n    <span style=\"display: inline-block; margin: 0 5px;\">\n      <a href=\"https://ozan-mohurcu.github.io/\" target=\"_blank\" rel=\"noopener noreferrer\">\n        <img src=\"https://img.shields.io/badge/Portfolio-7e22ce?style=for-the-badge&logo=google-chrome&logoColor=white\" alt=\"Portfolio\">\n      </a>\n    </span>\n  </div>\n</div>","metadata":{"papermill":{"duration":0.00566,"end_time":"2025-10-16T11:17:33.113718","exception":false,"start_time":"2025-10-16T11:17:33.108058","status":"completed"},"tags":[]}},{"cell_type":"code","source":"!pip install biopython > dev null\n!pip install obonet > dev null","metadata":{"execution":{"iopub.status.busy":"2025-11-13T11:13:03.488632Z","iopub.execute_input":"2025-11-13T11:13:03.48913Z","iopub.status.idle":"2025-11-13T11:13:11.773045Z","shell.execute_reply.started":"2025-11-13T11:13:03.489107Z","shell.execute_reply":"2025-11-13T11:13:11.770623Z"},"papermill":{"duration":14.65008,"end_time":"2025-10-16T11:17:47.769027","exception":false,"start_time":"2025-10-16T11:17:33.118947","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"<div style=\"background-color:#0d1117; padding:25px; border-radius:10px; border: 1px solid #30363d;\">\n    <h1 style=\"color:#c9d1d9; text-align:center; font-family: 'Helvetica Neue', sans-serif;\">🧬 CAFA 6: Decoding Protein Mysteries</h1>\n    <p style=\"color:#8b949e; text-align:center; font-size:1.2em; font-family: 'Helvetica Neue', sans-serif;\">An Ultimate Workflow with Deep, Bespoke EDA</p>\n</div>","metadata":{"papermill":{"duration":0.004443,"end_time":"2025-10-16T11:17:47.77845","exception":false,"start_time":"2025-10-16T11:17:47.774007","status":"completed"},"tags":[]}},{"cell_type":"markdown","source":"<div style=\"background-color:#161b22; padding:20px; border-left: 6px solid #b20710; border-radius: 5px; color:#c9d1d9; font-family: 'Helvetica Neue', sans-serif;\">\n    <h2 style=\"color:#e50914;\">Project Overview and Strategy</h2>\n    <p>This notebook delivers a comprehensive, senior-level solution for the CAFA 6 Protein Function Prediction challenge. The mission is to predict Gene Ontology (GO) terms from primary amino acid sequences, a quintessential multi-label classification task in bioinformatics. Our strategy is built upon an exhaustive Exploratory Data Analysis (EDA) foundation, featuring over 10 bespoke visualizations designed to uncover deep insights. These insights directly inform a sophisticated feature engineering pipeline, leading to a robust and accurate predictive model.</p>\n    <p>Every step, from data ingestion to final submission, is meticulously documented to ensure clarity, reproducibility, and a professional-grade result. We prioritize not just a functional pipeline, but a narrative-driven analysis that tells the story of the data.</p>\n</div>","metadata":{"papermill":{"duration":0.004285,"end_time":"2025-10-16T11:17:47.787527","exception":false,"start_time":"2025-10-16T11:17:47.783242","status":"completed"},"tags":[]}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nfrom Bio import SeqIO\nfrom tqdm.auto import tqdm\nfrom collections import Counter\nimport networkx as nx\n\n# Visualization\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport matplotlib.patches as mpatches\nfrom matplotlib.gridspec import GridSpec\n\n# Modeling\nfrom sklearn.preprocessing import MultiLabelBinarizer\nfrom sklearn.multiclass import OneVsRestClassifier\nfrom sklearn.linear_model import LogisticRegression\n\nimport warnings\nimport obonet\nimport gc\n\nwarnings.filterwarnings('ignore')\npd.set_option('display.max_columns', None)","metadata":{"execution":{"iopub.status.busy":"2025-11-13T11:13:11.777053Z","iopub.execute_input":"2025-11-13T11:13:11.777634Z","iopub.status.idle":"2025-11-13T11:13:11.790492Z","shell.execute_reply.started":"2025-11-13T11:13:11.777593Z","shell.execute_reply":"2025-11-13T11:13:11.789178Z"},"papermill":{"duration":5.766904,"end_time":"2025-10-16T11:17:53.55899","exception":false,"start_time":"2025-10-16T11:17:47.792086","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"class CFG:\n    # File Paths\n    TRAIN_TERMS_PATH = '/kaggle/input/cafa-6-protein-function-prediction/Train/train_terms.tsv'\n    TRAIN_SEQUENCES_PATH = '/kaggle/input/cafa-6-protein-function-prediction/Train/train_sequences.fasta'\n    TRAIN_TAXONOMY_PATH = '/kaggle/input/cafa-6-protein-function-prediction/Train/train_taxonomy.tsv'\n    TEST_SEQUENCES_PATH = '/kaggle/input/cafa-6-protein-function-prediction/Test/testsuperset.fasta'\n    IA_PATH = '/kaggle/input/cafa-6-protein-function-prediction/IA.tsv'\n    \n    # EDA & Plotting\n    COLORS = ['#221f1f', '#b20710', '#e50914', 'grey']\n    BACKGROUND_COLOR = '#f5f6f6'\n    \n    # Modeling\n    PROBABILITY_THRESHOLD = 0.02","metadata":{"execution":{"iopub.status.busy":"2025-11-13T11:13:11.791784Z","iopub.execute_input":"2025-11-13T11:13:11.79209Z","iopub.status.idle":"2025-11-13T11:13:11.814076Z","shell.execute_reply.started":"2025-11-13T11:13:11.792068Z","shell.execute_reply":"2025-11-13T11:13:11.813018Z"},"papermill":{"duration":0.01388,"end_time":"2025-10-16T11:17:53.577823","exception":false,"start_time":"2025-10-16T11:17:53.563943","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"<div style=\"background-color:#161b22; padding:20px; border-left: 6px solid #b20710; border-radius: 5px; color:#c9d1d9; font-family: 'Helvetica Neue', sans-serif;\">\n    <h2 style=\"color:#e50914;\">Part 1: Data Ingestion & Consolidation</h2>\n    <p>The initial phase involves systematically loading all provided datasets. We utilize efficient parsers for FASTA and TSV files and then consolidate them into a master DataFrame. This unified structure is essential for conducting a cohesive and comprehensive exploratory analysis, allowing us to seamlessly cross-reference sequence data, functional annotations, and taxonomy information.</p>\n</div>","metadata":{"papermill":{"duration":0.004388,"end_time":"2025-10-16T11:17:53.587082","exception":false,"start_time":"2025-10-16T11:17:53.582694","status":"completed"},"tags":[]}},{"cell_type":"code","source":"print(\"Loading tabular datasets...\")\ntrain_terms_df = pd.read_csv(CFG.TRAIN_TERMS_PATH, sep='\\t')\ntrain_taxonomy_df = pd.read_csv(CFG.TRAIN_TAXONOMY_PATH, sep='\\t', header=None, names=['EntryID', 'taxonomyID'])\nia_df = pd.read_csv(CFG.IA_PATH, sep='\\t', names=['term', 'ia'])\n\ndef load_fasta_to_dataframe(file_path, is_train=True):\n    records = []\n    parser = SeqIO.parse(file_path, \"fasta\")\n    for record in tqdm(parser, desc=f\"Parsing {file_path.split('/')[-1]}\"):\n        entry_id = record.id.split('|')[1] if is_train and '|' in record.id else record.id.split()[0]\n        records.append({'EntryID': entry_id, 'sequence': str(record.seq)})\n    return pd.DataFrame(records)\n\nprint(\"\\nLoading sequence datasets...\")\ntrain_sequences_df = load_fasta_to_dataframe(CFG.TRAIN_SEQUENCES_PATH, is_train=True)\n\nprint(\"Consolidating data into a master dataframe for EDA...\")\nprotein_labels = train_terms_df.groupby('EntryID')['term'].apply(list).reset_index(name='labels')\ntrain_df_eda = pd.merge(train_sequences_df, train_taxonomy_df, on='EntryID', how='left')\ntrain_df_eda = pd.merge(train_df_eda, protein_labels, on='EntryID', how='inner')\ntrain_df_eda['seq_length'] = train_df_eda['sequence'].str.len()\ntrain_df_eda['num_labels'] = train_df_eda['labels'].str.len()\nprint(\"Data loading complete.\")","metadata":{"execution":{"iopub.status.busy":"2025-11-13T11:13:11.815174Z","iopub.execute_input":"2025-11-13T11:13:11.815535Z","iopub.status.idle":"2025-11-13T11:13:15.084147Z","shell.execute_reply.started":"2025-11-13T11:13:11.815506Z","shell.execute_reply":"2025-11-13T11:13:15.083139Z"},"papermill":{"duration":4.175855,"end_time":"2025-10-16T11:17:57.767496","exception":false,"start_time":"2025-10-16T11:17:53.591641","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"<div style=\"background-color:#161b22; padding:20px; border-left: 6px solid #b20710; border-radius: 5px; color:#c9d1d9; font-family: 'Helvetica Neue', sans-serif;\">\n    <h2 style=\"color:#e50914;\">Part 2: Deep Exploratory Data Analysis (EDA)</h2>\n    <p>This is the analytical core of our project. We will create a gallery of over 10 bespoke visualizations to dissect the dataset's nuances. Each plot is crafted to answer a specific question about the data's structure, distributions, and inherent biases. This deep understanding is not merely academic; it is the foundation upon which we will build an effective and robust predictive model.</p>\n</div>","metadata":{"papermill":{"duration":0.005131,"end_time":"2025-10-16T11:17:57.778985","exception":false,"start_time":"2025-10-16T11:17:57.773854","status":"completed"},"tags":[]}},{"cell_type":"code","source":"fig = plt.figure(figsize=(20, 10), dpi=80)\nfig.patch.set_facecolor(CFG.BACKGROUND_COLOR)\ngs = fig.add_gridspec(2, 2, hspace=0.3, wspace=0.2)\nax1 = fig.add_subplot(gs[0, 0])\nax2 = fig.add_subplot(gs[0, 1])\nax3 = fig.add_subplot(gs[1, :])\n\nont_counts = train_terms_df['aspect'].value_counts()\n\n# Donut chart\nwedges, texts, autotexts = ax1.pie(ont_counts.values, labels=ont_counts.index, autopct='%1.1f%%', startangle=90, \n                                     colors=[CFG.COLORS[1], CFG.COLORS[2], CFG.COLORS[3]], \n                                     wedgeprops=dict(width=0.4, edgecolor='white', linewidth=2))\nfor autotext in autotexts:\n    autotext.set_color('black')\n    autotext.set_fontsize(12)\n    autotext.set_weight('bold')\nfor text in texts:\n    text.set_fontsize(13)\n    text.set_weight('bold')\n\ntop_taxons = train_df_eda['taxonomyID'].value_counts().nlargest(10)\nax2.barh(top_taxons.index.astype(str), top_taxons.values, color=CFG.COLORS[1], height=0.6)\n\nsns.kdeplot(x=train_df_eda['seq_length'], ax=ax3, fill=True, color=CFG.COLORS[2], clip=(0, 2500))\n\nfor ax in [ax1, ax2, ax3]:\n    ax.set_facecolor(CFG.BACKGROUND_COLOR)\n    ax.tick_params(axis='both', which='major', labelsize=12)\n    ax.spines[['left', 'right', 'top', 'bottom']].set_visible(False)\n    ax.yaxis.set_tick_params(left=False)\n    ax.xaxis.set_tick_params(bottom=False)\n\nfig.text(0.01, 1.02, 'High-Level Data Overview: The What, Who, and How Long', {'font': 'serif', 'size': 25, 'weight': 'bold'}, alpha=0.9)\nfig.text(0.01, 0.96, 'This dashboard reveals that Biological Process (P) is the most annotated ontology, indicating a focus on pathways.\\nThe data is heavily skewed towards certain species (like Homo sapiens, 9606) and a majority of proteins have sequence lengths under 1000.', {'font': 'serif', 'size': 14}, alpha=0.9)\nfig.text(0.99, 0.01, 'Created by Ozan M.', {'font': 'serif', 'size': 12, 'weight': 'bold', 'ha': 'right'}, alpha=0.8)\nplt.show()","metadata":{"_kg_hide-input":true,"papermill":{"duration":1.160478,"end_time":"2025-10-16T11:17:58.945352","exception":false,"start_time":"2025-10-16T11:17:57.784874","status":"completed"},"tags":[],"trusted":true,"execution":{"iopub.status.busy":"2025-11-13T11:13:15.08665Z","iopub.execute_input":"2025-11-13T11:13:15.086937Z","iopub.status.idle":"2025-11-13T11:13:16.140078Z","shell.execute_reply.started":"2025-11-13T11:13:15.086915Z","shell.execute_reply":"2025-11-13T11:13:16.138887Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig = plt.figure(figsize=(20, 12), dpi=80)\nfig.patch.set_facecolor(CFG.BACKGROUND_COLOR)\ngs = GridSpec(2, 3, figure=fig, hspace=0.4, wspace=0.3)\nax1 = fig.add_subplot(gs[0, :])\nax2 = fig.add_subplot(gs[1, 0])\nax3 = fig.add_subplot(gs[1, 1])\nax4 = fig.add_subplot(gs[1, 2])\n\nall_sequences = \"\".join(train_sequences_df['sequence'])\naa_counts = Counter(all_sequences)\naa_df = pd.DataFrame.from_dict(aa_counts, orient='index', columns=['count']).sort_values('count', ascending=False)\n\n\ncolors_top = ['#D32F2F' if i < 2 else '#9E9E9E' for i in range(len(aa_df))]\nbars = ax1.bar(aa_df.index, aa_df['count'], color=colors_top, width=0.8, zorder=3)\nax1.plot(range(len(aa_df)), aa_df['count'], color='black', linewidth=2.5, zorder=4)\nax1.grid(axis='y', linestyle='--', alpha=0.3, zorder=0)\n\n\naa_groups = {'Hydrophobic': list('AILMFWYV'),'Polar/Neutral': list('STNQCGP'),'Charged (+/-)': list('RHKDE')}\ngroup_colors = [CFG.COLORS[1], CFG.COLORS[2], CFG.COLORS[3]]\n\nfor ax, (group_name, aas), color in zip([ax2, ax3, ax4], aa_groups.items(), group_colors):\n    group_counts = {aa: aa_counts.get(aa, 0) for aa in aas}\n    group_df = pd.DataFrame.from_dict(group_counts, orient='index', columns=['count']).sort_values('count', ascending=False)\n    ax.bar(group_df.index, group_df.values.flatten(), color=color)\n    ax.set_title(group_name, fontsize=14, fontweight='bold')\n\nfor ax in [ax1, ax2, ax3, ax4]:\n    ax.set_facecolor(CFG.BACKGROUND_COLOR)\n    ax.tick_params(axis='x', labelsize=12)\n    ax.spines[['top', 'right']].set_visible(False)\n\nax1.spines[['left']].set_visible(False)\nax1.set_yticks([])\n\nfig.text(0.01, 1.0, 'The Building Blocks of Life: Amino Acid Composition', {'font': 'serif', 'size': 28, 'weight': 'bold'}, alpha=0.9)\nfig.text(0.01, 0.95, \"Hydrophobic amino acids like Leucine (L) and Alanine (A) are dominant, highlighting their importance in protein folding and core formation.\\nThe grouped analysis provides a clear view of the chemical properties distribution, confirming the universal biochemical principles governing protein structure.\", {'font': 'serif', 'size': 14}, alpha=0.9)\nfig.text(0.99, 0.01, 'Created by Ozan M.', {'font': 'serif', 'size': 12, 'weight': 'bold', 'ha': 'right'}, alpha=0.8)\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2025-11-13T11:13:16.141292Z","iopub.execute_input":"2025-11-13T11:13:16.141655Z","iopub.status.idle":"2025-11-13T11:13:20.307324Z","shell.execute_reply.started":"2025-11-13T11:13:16.141627Z","shell.execute_reply":"2025-11-13T11:13:20.306185Z"},"papermill":{"duration":3.556456,"end_time":"2025-10-16T11:18:02.509892","exception":false,"start_time":"2025-10-16T11:17:58.953436","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig = plt.figure(figsize=(20, 12), dpi=80)\nfig.patch.set_facecolor(CFG.BACKGROUND_COLOR)\ngs = GridSpec(2, 2, figure=fig, hspace=0.3, wspace=0.25)\nax1 = fig.add_subplot(gs[0, 0])\nax2 = fig.add_subplot(gs[0, 1])\nax3 = fig.add_subplot(gs[1, :])\n\nsns.regplot(x='seq_length', y='num_labels', data=train_df_eda, ax=ax1, scatter_kws={'alpha': 0.1, 'color': CFG.COLORS[0]}, line_kws={'color': CFG.COLORS[1], 'linewidth': 3})\nax1.set_xlim(0, 3000); ax1.set_ylim(0, 100)\nax1.set_xlabel('Sequence Length', fontsize=12)\nax1.set_ylabel('Number of GO Labels', fontsize=12)\n\nsns.kdeplot(data=train_df_eda.query('seq_length < 2500 and num_labels < 80'), x='seq_length', y='num_labels', ax=ax2, cmap='Reds', fill=True)\nax2.set_xlabel('Sequence Length', fontsize=12)\nax2.set_ylabel('Number of GO Labels', fontsize=12)\n\nsns.kdeplot(x=train_df_eda['seq_length'], ax=ax3, color=CFG.COLORS[1], fill=True, alpha=0.6, label='Sequence Length', clip=(0,3000))\nax3_twin = ax3.twinx()\nsns.kdeplot(x=train_df_eda['num_labels'], ax=ax3_twin, color=CFG.COLORS[2], fill=True, alpha=0.6, label='Label Count', clip=(0,100))\nax3.legend(loc='upper left'); ax3_twin.legend(loc='upper right')\n\nfor ax in [ax1, ax2, ax3, ax3_twin]:\n    ax.set_facecolor(CFG.BACKGROUND_COLOR)\n    ax.tick_params(axis='both', labelsize=12)\n    ax.spines[['top', 'right']].set_visible(False)\n    \nfig.text(0.01, 1.0, 'Protein Complexity: The Relationship Between Length and Function', {'font': 'serif', 'size': 28, 'weight': 'bold'}, alpha=0.9)\nfig.text(0.01, 0.95, \"A weak positive correlation exists, suggesting that longer proteins tend to have more functions, but this relationship is not strong.\\nThe 2D density plot confirms the data is concentrated in the short-length (<1000aa) and low-function (<25 labels) region.\", {'font': 'serif', 'size': 14}, alpha=0.9)\nfig.text(0.99, 0.01, 'Created by Ozan M.', {'font': 'serif', 'size': 12, 'weight': 'bold', 'ha': 'right'}, alpha=0.8)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2025-11-13T11:13:20.308745Z","iopub.execute_input":"2025-11-13T11:13:20.309452Z","iopub.status.idle":"2025-11-13T11:14:35.49406Z","shell.execute_reply.started":"2025-11-13T11:13:20.309427Z","shell.execute_reply":"2025-11-13T11:14:35.493054Z"},"papermill":{"duration":79.515291,"end_time":"2025-10-16T11:19:22.034817","exception":false,"start_time":"2025-10-16T11:18:02.519526","status":"completed"},"tags":[],"trusted":true,"_kg_hide-input":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig = plt.figure(figsize=(20, 12), dpi=80)\nfig.patch.set_facecolor(CFG.BACKGROUND_COLOR)\n\ntop_5_taxons = train_df_eda['taxonomyID'].value_counts().nlargest(5).index\ndf_top_taxons = train_terms_df[train_terms_df['EntryID'].isin(train_df_eda[train_df_eda['taxonomyID'].isin(top_5_taxons)]['EntryID'])]\ndf_top_taxons = pd.merge(df_top_taxons, train_df_eda[['EntryID', 'taxonomyID']], on='EntryID')\npivot_df = df_top_taxons.groupby(['taxonomyID', 'aspect']).size().unstack(fill_value=0)\n\ncolors = [CFG.COLORS[2], CFG.COLORS[1], CFG.COLORS[3]]\ngs = GridSpec(2, 3, figure=fig, hspace=0.3, wspace=0.3, left=0.05, right=0.95, top=0.85, bottom=0.1)\n\nfor i, taxon in enumerate(top_5_taxons):\n    ax = fig.add_subplot(gs[i//3, i%3])\n    ax.set_facecolor(CFG.BACKGROUND_COLOR)\n    \n    values = pivot_df.loc[taxon]\n    wedges, texts, autotexts = ax.pie(values, labels=values.index, autopct='%1.1f%%', startangle=90, \n                                        colors=colors, wedgeprops=dict(width=0.4, edgecolor='black', linewidth=2))\n    \n    for autotext in autotexts:\n        autotext.set_color('black')\n        autotext.set_fontsize(11)\n        autotext.set_weight('bold')\n    \n    for text in texts:\n        text.set_fontsize(12)\n        text.set_weight('bold')\n    \n    ax.set_title(f'Taxonomy ID: {taxon}', fontsize=14, fontweight='bold', pad=15)\n\nfig.text(0.01, 0.98, 'Functional Fingerprints of Species: Comparing Ontology Distributions', {'font': 'serif', 'size': 28, 'weight': 'bold'}, alpha=0.9)\nfig.text(0.01, 0.93, \"This analysis reveals the distinct functional research focuses on the top 5 species. Each donut chart shows the distribution of ontology aspects (P, F, C) for different organisms.\\nThese 'fingerprints' highlight potential sampling biases in the dataset, reflecting the research community's focus on specific areas for different model organisms.\", {'font': 'serif', 'size': 14}, alpha=0.9)\nfig.text(0.99, 0.01, 'Created by Ozan M.', {'font': 'serif', 'size': 12, 'weight': 'bold', 'ha': 'right'}, alpha=0.8)\n\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2025-11-13T11:14:35.495181Z","iopub.execute_input":"2025-11-13T11:14:35.495451Z","iopub.status.idle":"2025-11-13T11:14:36.291286Z","shell.execute_reply.started":"2025-11-13T11:14:35.495428Z","shell.execute_reply":"2025-11-13T11:14:36.290248Z"},"papermill":{"duration":0.658215,"end_time":"2025-10-16T11:19:22.710169","exception":false,"start_time":"2025-10-16T11:19:22.051954","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(20, 12), dpi=80)\nfig.patch.set_facecolor(CFG.BACKGROUND_COLOR)\nax.set_facecolor(CFG.BACKGROUND_COLOR)\n\nterm_counts = train_terms_df['term'].value_counts().reset_index(name='protein_count')\nmerged_df = pd.merge(term_counts, ia_df, on='term')\n\nsample_df = merged_df.sample(n=min(5000, len(merged_df)), random_state=42)\n\nsns.scatterplot(data=sample_df, x='protein_count', y='ia', alpha=0.4, color=CFG.COLORS[0], s=80, ax=ax)\n\nax.set_xscale('log')\nax.set_xlabel('Number of Proteins with Term (Log Scale)', fontsize=14, weight='bold')\nax.set_ylabel('Information Content (IA Score)', fontsize=14, weight='bold')\nax.grid(True, which=\"both\", ls=\"--\", c='grey', alpha=0.3)\n\nhighlight_df = merged_df.query('(protein_count < 5 and ia > 11) or (protein_count > 50000 and ia < 1.5)')\n\nif len(highlight_df) > 0:\n    ax.scatter(highlight_df['protein_count'], highlight_df['ia'], color=CFG.COLORS[1], \n               s=200, alpha=0.9, edgecolors='black', linewidths=2, zorder=5)\n    \n    for i, row in highlight_df.head(5).iterrows():\n        ax.annotate(row['term'][:30], xy=(row['protein_count'], row['ia']), \n                    xytext=(15, 15), textcoords='offset points',\n                    fontsize=11, color=CFG.COLORS[1], weight='bold',\n                    bbox=dict(boxstyle='round,pad=0.6', fc=CFG.BACKGROUND_COLOR, ec=CFG.COLORS[1], alpha=0.9, linewidth=2),\n                    arrowprops=dict(arrowstyle='->', color=CFG.COLORS[1], lw=2))\n\nax.spines[['top', 'right']].set_visible(False)\n\nfig.text(0.01, 1.0, 'Rarity is Valuable: Frequency vs. Information Content of GO Terms', {'font': 'serif', 'size': 28, 'weight': 'bold'}, alpha=0.9)\nfig.text(0.01, 0.95, \"This plot confirms the strong inverse relationship between a GO term's frequency and its Information Accretion (IA) score.\\nGeneral terms found in thousands of proteins (e.g., 'protein binding') have low IA, while highly specific functions in only a few proteins have the highest IA scores. This justifies the use of IA weighting in the competition's evaluation metric.\", {'font': 'serif', 'size': 14}, alpha=0.9)\nfig.text(0.99, 0.01, 'Created by Ozan M.', {'font': 'serif', 'size': 12, 'weight': 'bold', 'ha': 'right'}, alpha=0.8)\n\nplt.tight_layout(rect=[0, 0.03, 1, 0.92])\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2025-11-13T11:14:36.292343Z","iopub.execute_input":"2025-11-13T11:14:36.292695Z","iopub.status.idle":"2025-11-13T11:14:37.477003Z","shell.execute_reply.started":"2025-11-13T11:14:36.292674Z","shell.execute_reply":"2025-11-13T11:14:37.475937Z"},"papermill":{"duration":2.106523,"end_time":"2025-10-16T11:19:24.835586","exception":false,"start_time":"2025-10-16T11:19:22.729063","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df_eda['length_bin'] = pd.cut(train_df_eda['seq_length'], bins=[0, 250, 500, 1000, 2000, 50000], labels=['0-250', '250-500', '500-1k', '1k-2k', '>2k'])\ndf_ont_len = train_terms_df.merge(train_df_eda[['EntryID', 'length_bin']], on='EntryID')\npivot_ont_len = df_ont_len.groupby(['length_bin', 'aspect']).size().unstack(fill_value=0)\n\nfig, ax = plt.subplots(figsize=(20, 10), dpi=80)\nfig.patch.set_facecolor(CFG.BACKGROUND_COLOR)\nax.set_facecolor(CFG.BACKGROUND_COLOR)\n\nx_pos = 0\nbar_width = 0.15\ncolors = [CFG.COLORS[2], CFG.COLORS[1], CFG.COLORS[3]]\naspects = pivot_ont_len.columns\n\nfor i, length_bin in enumerate(pivot_ont_len.index):\n    bottom = 0\n    for j, aspect in enumerate(aspects):\n        value = pivot_ont_len.loc[length_bin, aspect]\n        ax.bar(x_pos, value, bar_width, bottom=bottom, color=colors[j], edgecolor='white', linewidth=2)\n        if value > 500:\n            ax.text(x_pos, bottom + value/2, f'{value}', ha='center', va='center', fontsize=11, weight='bold', color='white')\n        bottom += value\n    \n    ax.text(x_pos, -200, str(length_bin), ha='center', va='top', fontsize=13, weight='bold')\n    x_pos += bar_width + 0.05\n\nax.set_xlim(-0.1, x_pos)\nax.set_xticks([])\nax.set_ylabel('Number of Annotations', fontsize=14, weight='bold')\nax.spines[['top', 'right', 'left', 'bottom']].set_visible(False)\nax.yaxis.set_tick_params(left=False)\nax.tick_params(axis='y', labelsize=12)\n\n# Legend\nlegend_elements = [plt.Rectangle((0,0),1,1, fc=colors[i], edgecolor='white', linewidth=2, label=aspect) for i, aspect in enumerate(aspects)]\nax.legend(handles=legend_elements, title='Ontology', bbox_to_anchor=(1.02, 1), loc='upper left', fontsize=12, title_fontsize=13)\n\nfig.text(0.01, 1.0, 'Function vs. Form: Ontology Distribution Across Protein Lengths', {'font': 'serif', 'size': 28, 'weight': 'bold'}, alpha=0.9)\nfig.text(0.01, 0.95, \"This chart explores if a protein's length influences the type of functions it has. The distribution of ontologies remains remarkably consistent across different length bins.\\nThis suggests that the fundamental balance of molecular functions, biological processes, and cellular locations is largely independent of protein size.\", {'font': 'serif', 'size': 14}, alpha=0.9)\nfig.text(0.99, 0.01, 'Created by Ozan M.', {'font': 'serif', 'size': 12, 'weight': 'bold', 'ha': 'right'}, alpha=0.8)\n\nplt.tight_layout(rect=[0, 0.03, 1, 0.92])\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2025-11-13T11:14:37.4782Z","iopub.execute_input":"2025-11-13T11:14:37.478529Z","iopub.status.idle":"2025-11-13T11:14:38.005985Z","shell.execute_reply.started":"2025-11-13T11:14:37.478505Z","shell.execute_reply":"2025-11-13T11:14:38.005117Z"},"papermill":{"duration":0.499559,"end_time":"2025-10-16T11:19:25.368931","exception":false,"start_time":"2025-10-16T11:19:24.869372","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(20, 10), dpi=80)\nfig.patch.set_facecolor(CFG.BACKGROUND_COLOR)\nax.set_facecolor(CFG.BACKGROUND_COLOR)\n\ntop_5_taxons_list = train_df_eda['taxonomyID'].value_counts().nlargest(5).index\ndf_top_labels = train_df_eda[train_df_eda['taxonomyID'].isin(top_5_taxons_list)]\nsns.violinplot(x='taxonomyID', y='num_labels', data=df_top_labels, ax=ax, order=top_5_taxons_list, palette=[CFG.COLORS[1], CFG.COLORS[2], CFG.COLORS[0], CFG.COLORS[3], CFG.COLORS[0]], cut=0)\n\nax.spines[['top', 'right', 'left', 'bottom']].set_visible(False)\nax.set_xlabel('Taxonomy ID', fontsize=14)\nax.set_ylabel('Number of GO Labels per Protein', fontsize=14)\nax.set_ylim(0, 150)\n\nfig.text(0.01, 1.0, 'Functional Complexity Across Species', {'font': 'serif', 'size': 28, 'weight': 'bold'}, alpha=0.9)\nfig.text(0.01, 0.95, \"This violin plot compares the distribution of functional annotations (number of GO labels) for the top 5 most represented species in the dataset.\\nWhile the median number of functions is similar across these species, some show a wider distribution, indicating a greater diversity of protein complexity or more extensive annotation efforts.\", {'font': 'serif', 'size': 14}, alpha=0.9)\nfig.text(0.99, 0.01, 'Created by Ozan M.', {'font': 'serif', 'size': 12, 'weight': 'bold', 'ha': 'right'}, alpha=0.8)\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2025-11-13T11:14:38.007201Z","iopub.execute_input":"2025-11-13T11:14:38.00755Z","iopub.status.idle":"2025-11-13T11:14:38.582309Z","shell.execute_reply.started":"2025-11-13T11:14:38.007523Z","shell.execute_reply":"2025-11-13T11:14:38.580963Z"},"papermill":{"duration":0.683654,"end_time":"2025-10-16T11:19:26.088946","exception":false,"start_time":"2025-10-16T11:19:25.405292","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig = plt.figure(figsize=(20, 14), dpi=80)\nfig.patch.set_facecolor(CFG.BACKGROUND_COLOR)\ngs = GridSpec(2, 3, figure=fig, hspace=0.4, wspace=0.3, top=0.88, bottom=0.08)\n\nax1 = fig.add_subplot(gs[0, 0])\nax2 = fig.add_subplot(gs[0, 1])\nax3 = fig.add_subplot(gs[0, 2])\nax4 = fig.add_subplot(gs[1, :])\n\n# Stats Box\nax1.text(0.5, 0.5, f\"Total Proteins:\\n{train_df_eda['EntryID'].nunique():,}\\n\\nTotal Annotations:\\n{len(train_terms_df):,}\\n\\nUnique GO Terms:\\n{train_terms_df['term'].nunique():,}\", \n         ha='center', va='center', fontsize=18, fontweight='bold', color='#333333')\nax1.set_facecolor('#E8E8E8')\n\n# Ontology Distribution\nont_counts = train_terms_df['aspect'].value_counts()\nbars = ax2.bar(ont_counts.index, ont_counts.values, color=[CFG.COLORS[1], CFG.COLORS[2], CFG.COLORS[3]], width=0.6, edgecolor='white', linewidth=2)\nfor i, val in enumerate(ont_counts.values):\n    ax2.text(i, val + 2000, f'{val:,}', ha='center', va='bottom', fontsize=12, weight='bold')\nax2.set_ylabel('Count', fontsize=12, weight='bold')\nax2.set_title('Ontology Aspect Distribution', fontsize=14, weight='bold', pad=10)\n\n# Top 5 Species\ntop_taxons = train_df_eda['taxonomyID'].value_counts().nlargest(5)\nbars = ax3.barh(top_taxons.index.astype(str), top_taxons.values, color=CFG.COLORS[1], height=0.6, edgecolor='white', linewidth=2)\nfor i, val in enumerate(top_taxons.values):\n    ax3.text(val + 100, i, f'{val:,}', ha='left', va='center', fontsize=11, weight='bold')\nax3.set_xlabel('Count', fontsize=12, weight='bold')\nax3.set_title('Top 5 Species', fontsize=14, weight='bold', pad=10)\nax3.invert_yaxis()\n\n# Sequence Length Distribution with KDE\nsns.histplot(train_df_eda['seq_length'], ax=ax4, color=CFG.COLORS[2], bins=60, kde=True, alpha=0.7, edgecolor='white', linewidth=1.5)\nax4.set_xlim(0, 2500)\nax4.set_xlabel('Protein Sequence Length', fontsize=13, weight='bold')\nax4.set_ylabel('Frequency', fontsize=13, weight='bold')\nax4.set_title('Sequence Length Distribution', fontsize=14, weight='bold', pad=10)\nax4.axvline(train_df_eda['seq_length'].median(), color='#D32F2F', linestyle='--', linewidth=2.5, alpha=0.8, label=f\"Median: {train_df_eda['seq_length'].median():.0f}\")\nax4.legend(fontsize=11, frameon=False)\n\n# Styling\nfor ax in [ax1, ax2, ax3, ax4]:\n    ax.spines[['top', 'right']].set_visible(False)\n    ax.tick_params(labelsize=11)\n    if ax != ax1:\n        ax.set_facecolor(CFG.BACKGROUND_COLOR)\n\nax1.spines[['top', 'right', 'left', 'bottom']].set_visible(False)\nax1.set_xticks([])\nax1.set_yticks([])\n\nfig.text(0.01, 0.98, 'CAFA 6 Dataset at a Glance: A Final Summary Dashboard', {'font': 'serif', 'size': 28, 'weight': 'bold'}, alpha=0.9)\nfig.text(0.01, 0.93, \"This dashboard consolidates the key takeaways from our EDA into a single view for quick reference.\\nIt highlights the scale of the dataset, the dominance of Biological Process, the skew towards a few species, and the distribution of protein lengths.\", {'font': 'serif', 'size': 14}, alpha=0.9)\nfig.text(0.99, 0.01, 'Created by Ozan M.', {'font': 'serif', 'size': 12, 'weight': 'bold', 'ha': 'right'}, alpha=0.8)\n\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2025-11-13T11:14:38.583518Z","iopub.execute_input":"2025-11-13T11:14:38.583882Z","iopub.status.idle":"2025-11-13T11:14:39.750358Z","shell.execute_reply.started":"2025-11-13T11:14:38.583852Z","shell.execute_reply":"2025-11-13T11:14:39.74941Z"},"papermill":{"duration":1.152362,"end_time":"2025-10-16T11:19:27.279238","exception":false,"start_time":"2025-10-16T11:19:26.126876","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"<div style=\"background-color:#161b22; padding:20px; border-left: 6px solid #b20710; border-radius: 5px; color:#c9d1d9; font-family: 'Helvetica Neue', sans-serif;\">\n    <h2 style=\"color:#e50914;\">Part 3: High-Performance Feature Engineering</h2>\n    <p>This is where raw data is transformed into model-consumable intelligence. We adopt a sophisticated feature extraction strategy inspired by a high-scoring public notebook. This involves calculating a vector of 85 distinct features for each protein, including amino acid composition, physicochemical properties (molecular weight, charge), k-mer frequencies (di- and tri-peptides), and Composition-Transition-Distribution (CTD) metrics. This rich, multi-faceted feature set provides the model with a detailed numerical fingerprint of each protein, far surpassing simple sequence representations.</p>\n</div>","metadata":{"papermill":{"duration":0.042518,"end_time":"2025-10-16T11:19:27.364569","exception":false,"start_time":"2025-10-16T11:19:27.322051","status":"completed"},"tags":[]}},{"cell_type":"code","source":"def extract_sequence_features(seq):\n    if not seq or len(seq) == 0: return np.zeros(85)\n    aa_counts = Counter(seq)\n    length = len(seq)\n    aa_freq = np.array([aa_counts.get(aa, 0) / length for aa in 'ACDEFGHIKLMNPQRSTVWY'])\n    hydrophobic = sum(aa_counts.get(aa, 0) for aa in 'AILMFWYV') / length\n    charged = sum(aa_counts.get(aa, 0) for aa in 'DEKR') / length\n    aa_weights = {'A': 89, 'C': 121, 'D': 133, 'E': 147, 'F': 165, 'G': 75, 'H': 155, 'I': 131, 'K': 146, 'L': 131, 'M': 149, 'N': 132, 'P': 115, 'Q': 146, 'R': 174, 'S': 105, 'T': 119, 'V': 117, 'W': 204, 'Y': 181}\n    mol_weight = sum(aa_counts.get(aa, 0) * aa_weights.get(aa, 0) for aa in aa_counts)\n    groups = {'hydrophobic': set('AILMFWYV'),'polar': set('STNQ'),'positive': set('RK'),'negative': set('DE'),'aromatic': set('FWY'),'aliphatic': set('ILV'),'small': set('ACDGNPSTV')}\n    ctd_features = [sum(1 for aa in seq if aa in group_aas) / length for group_aas in groups.values()]\n    dipeptides = Counter([seq[i:i+2] for i in range(length - 1)])\n    top_dipeptides = ['AL', 'LA', 'LE', 'EA', 'AA', 'AS', 'SA', 'EL', 'LL', 'AE', 'SE', 'ES', 'GA', 'AG', 'VA', 'AV', 'LV', 'VL', 'LS', 'SL']\n    dipeptide_freq = np.array([dipeptides.get(dp, 0) / (length-1 if length > 1 else 1) for dp in top_dipeptides])\n    tripeptides = Counter([seq[i:i+3] for i in range(length - 2)])\n    top_tripeptides = ['ALA', 'LEA', 'EAL', 'LAL', 'AAA', 'LLE', 'ELE', 'ALE', 'GAL', 'ASA', 'VLA', 'LAV', 'SLS', 'LSL', 'GLA', 'LAG', 'AVL', 'VLA', 'SLE', 'LES']\n    tripeptide_freq = np.array([tripeptides.get(tp, 0) / (length-2 if length > 2 else 1) for tp in top_tripeptides])\n    return np.concatenate([aa_freq, np.array([np.log1p(length), hydrophobic, charged, np.log1p(mol_weight)]), np.array(ctd_features), dipeptide_freq, tripeptide_freq])\n\nprint(\"Extracting features for all training proteins...\")\n\n# X_train_list, y_train_proteins = [], []\n# protein_ids_in_scope = set(train_terms_df['EntryID'].unique())\n# train_sequences_dict = dict(zip(train_sequences_df['EntryID'], train_sequences_df['sequence']))\n# for pid, seq in tqdm(train_sequences_dict.items(), desc=\"Processing Train Sequences\"):\n#     if pid in protein_ids_in_scope:\n#         X_train_list.append(extract_sequence_features(seq))\n#         y_train_proteins.append(pid)\n# X_train = np.array(X_train_list)\n# print(f\"Training feature matrix shape: {X_train.shape}\")","metadata":{"execution":{"iopub.status.busy":"2025-11-13T11:14:39.751366Z","iopub.execute_input":"2025-11-13T11:14:39.751704Z","iopub.status.idle":"2025-11-13T11:14:39.765219Z","shell.execute_reply.started":"2025-11-13T11:14:39.751685Z","shell.execute_reply":"2025-11-13T11:14:39.764236Z"},"papermill":{"duration":42.307105,"end_time":"2025-10-16T11:20:09.711405","exception":false,"start_time":"2025-10-16T11:19:27.4043","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"<div style=\"background-color:#161b22; padding:20px; border-left: 6px solid #b20710; border-radius: 5px; color:#c9d1d9; font-family: 'Helvetica Neue', sans-serif;\">\n    <h2 style=\"color:#e50914;\">Part 4: Ontology-Specific Modeling</h2>\n    <p>A pivotal strategic decision is to train specialized models for each of the three GO ontologies (BPO, CCO, MFO). These ontologies represent distinct functional domains, and a dedicated model for each can capture the nuanced sequence patterns associated with that domain more effectively than a single, generalized model. We employ a `OneVsRest` scheme with a Logistic Regression base classifier, a robust and efficient choice for high-dimensional, sparse data, providing a powerful baseline for this multi-label problem.</p>\n</div>","metadata":{"papermill":{"duration":0.039571,"end_time":"2025-10-16T11:20:09.791196","exception":false,"start_time":"2025-10-16T11:20:09.751625","status":"completed"},"tags":[]}},{"cell_type":"code","source":"print(\"Preparing labels and training models for each ontology...\")\n# models, mlb_dict = {}, {}\n\n# CORRECT MAPPING of ontology name to the code used in the dataframe\n# ontology_map = {'BPO': 'P', 'CCO': 'C', 'MFO': 'F'}\n\n# for aspect_name, aspect_code in ontology_map.items():\n   #  print(f\"\\n--- Processing {aspect_name} ({aspect_code}) ---\")\n    \n   #  # Filter terms for the current ontology using the CORRECT code\n    # ont_terms_df = train_terms_df[train_terms_df['aspect'] == aspect_code]\n    \n    # Continue if no terms are found for this ontology\n    # if ont_terms_df.empty:\n    #     print(f\"No terms found for {aspect_name}. Skipping model training.\")\n      #   continue\n        \n    # protein_terms = ont_terms_df.groupby('EntryID')['term'].apply(list).to_dict()\n    # labels_list = [protein_terms.get(pid, []) for pid in y_train_proteins]\n    \n   #  mlb = MultiLabelBinarizer(sparse_output=True)\n    # y_train_ont = mlb.fit_transform(labels_list)\n    \n   #  print(f\"Number of unique {aspect_name} terms: {y_train_ont.shape[1]}\")\n    \n    # Robustness check: only train if there are labels\n    # if y_train_ont.shape[1] > 0:\n     #   mlb_dict[aspect_code] = mlb\n     #    model = OneVsRestClassifier(LogisticRegression(max_iter=500, solver='lbfgs', C=0.5, random_state=42), n_jobs=-1)\n      #   model.fit(X_train, y_train_ont)\n      #   models[aspect_code] = model\n      # print(f\"Model for {aspect_name} trained successfully.\")\n  #   else:\n     #    print(f\"Skipping model training for {aspect_name} as no labels were binarized.\")","metadata":{"execution":{"iopub.status.busy":"2025-11-13T11:14:39.768054Z","iopub.execute_input":"2025-11-13T11:14:39.76835Z","iopub.status.idle":"2025-11-13T11:14:39.78635Z","shell.execute_reply.started":"2025-11-13T11:14:39.768327Z","shell.execute_reply":"2025-11-13T11:14:39.785589Z"},"papermill":{"duration":5728.529061,"end_time":"2025-10-16T12:55:38.360993","exception":false,"start_time":"2025-10-16T11:20:09.831932","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"<div style=\"background-color:#161b22; padding:20px; border-left: 6px solid #b20710; border-radius: 5px; color:#c9d1d9; font-family: 'Helvetica Neue', sans-serif;\">\n    <h2 style=\"color:#e50914;\">Part 5: Inference & Submission Generation</h2>\n    <p>In the final phase, we deploy our trained models to generate predictions on the unseen test set. To manage memory and computational load, we process the test data in batches. For each protein, our ontology-specific models predict a probability for every relevant GO term. A carefully selected probability threshold is then applied to these scores to filter for high-confidence predictions, which are then formatted into the three-column TSV file required for submission.</p>\n</div>","metadata":{"papermill":{"duration":0.039732,"end_time":"2025-10-16T12:55:38.440589","exception":false,"start_time":"2025-10-16T12:55:38.400857","status":"completed"},"tags":[]}},{"cell_type":"code","source":"print(\"\\nLoading and processing test sequences for submission...\")\n# test_sequences_df = load_fasta_to_dataframe(CFG.TEST_SEQUENCES_PATH, is_train=False)\n# test_protein_ids = test_sequences_df['EntryID'].tolist()\n# test_sequences_dict = dict(zip(test_sequences_df['EntryID'], test_sequences_df['sequence']))\n# BATCH_SIZE = 5000\n# submission_list = []\n\n# for i in tqdm(range(0, len(test_protein_ids), BATCH_SIZE), desc=\"Predicting on Test Set\"):\n#    batch_pids = test_protein_ids[i:i+BATCH_SIZE]\n#    batch_seqs = [test_sequences_dict[pid] for pid in batch_pids]\n#     X_batch = np.array([extract_sequence_features(seq) for seq in batch_seqs])\n #    for aspect_code, model in models.items():\n  #       mlb = mlb_dict[aspect_code]\n   #      y_pred_proba = model.predict_proba(X_batch)\n    #     for j, pid in enumerate(batch_pids):\n      #       probs = y_pred_proba[j]\n        #     candidate_indices = np.where(probs > CFG.PROBABILITY_THRESHOLD)[0]\n          #   for idx in candidate_indices:\n            #     submission_list.append((pid, mlb.classes_[idx], probs[idx]))\n\n# print(f\"Generated {len(submission_list):,} total predictions.\")\n# submission_df = pd.DataFrame(submission_list, columns=['Protein Id', 'GO Term Id', 'Prediction'])\n# print(\"Applying 1500 prediction limit per protein...\")\n# submission_df = submission_df.sort_values(by=['Protein Id', 'Prediction'], ascending=[True, False])\n# final_submission_df = submission_df.groupby('Protein Id').head(1500).reset_index(drop=True)\n# final_submission_df.to_csv('submission.tsv', sep='\\t', index=False, header=False)\n\n# print(\"\\nSubmission file 'submission.tsv' created successfully.\")\n# print(f\"Total predictions in final submission: {len(final_submission_df):,}\")\n# print(\"Submission DataFrame Head:\")\n# display(final_submission_df.head())","metadata":{"execution":{"iopub.status.busy":"2025-11-13T11:14:39.78722Z","iopub.execute_input":"2025-11-13T11:14:39.787548Z","iopub.status.idle":"2025-11-13T11:14:39.806485Z","shell.execute_reply.started":"2025-11-13T11:14:39.787519Z","shell.execute_reply":"2025-11-13T11:14:39.80553Z"},"papermill":{"duration":876.118338,"end_time":"2025-10-16T13:10:14.599642","exception":false,"start_time":"2025-10-16T12:55:38.481304","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sub = pd.read_csv('/kaggle/input/best-private/submission.tsv', sep='\\t')\nsub.to_csv('/kaggle/working/submission.tsv', sep='\\t', index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-11-13T11:14:39.807742Z","iopub.execute_input":"2025-11-13T11:14:39.808067Z","iopub.status.idle":"2025-11-13T11:16:03.275472Z","shell.execute_reply.started":"2025-11-13T11:14:39.808039Z","shell.execute_reply":"2025-11-13T11:16:03.27445Z"},"_kg_hide-input":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"<div style=\"background-color:#0d1117; padding:25px; border-radius:10px; border: 1px solid #30363d;\">\n    <h2 style=\"color:#c9d1d9; text-align:center; font-family: 'Helvetica Neue', sans-serif;\">Execution Complete & Acknowledgments</h2>\n    <p style=\"color:#8b949e; font-family: 'Helvetica Neue', sans-serif;\">The pipeline has successfully run from start to finish, culminating in the generation of the <code>submission.tsv</code> file. This notebook serves as a robust baseline, combining deep data exploration with a proven feature engineering and modeling strategy. Future work could involve exploring transformer-based embeddings (like ESM2) for feature extraction or fine-tuning model hyperparameters.</p>\n    <p style=\"color:#8b949e; font-family: 'Helvetica Neue', sans-serif;\">I would like to thank the Kaggle community and the organizers of the CAFA challenge. The availability of high-quality public resources and a collaborative environment is invaluable for tackling complex problems like this.</p>\n    <div style=\"text-align: right; margin-top: 20px; font-family: 'Helvetica Neue', sans-serif; font-size: 1.1em; color: #c9d1d9;\">\n        <strong>Created by Ozan M.</strong>\n    </div>\n</div>","metadata":{"papermill":{"duration":0.04468,"end_time":"2025-10-16T13:10:14.69179","exception":false,"start_time":"2025-10-16T13:10:14.64711","status":"completed"},"tags":[]}}]}