{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport requests\nimport json\nimport base64\nimport warnings\nwarnings.filterwarnings(\"ignore\")\n\nfrom sklearn.naive_bayes import GaussianNB","metadata":{"execution":{"iopub.status.busy":"2022-09-12T00:08:28.571269Z","iopub.execute_input":"2022-09-12T00:08:28.571703Z","iopub.status.idle":"2022-09-12T00:08:28.578805Z","shell.execute_reply.started":"2022-09-12T00:08:28.571671Z","shell.execute_reply":"2022-09-12T00:08:28.577284Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data = pd.read_json('../input/ai-village-ctf/murderbots/train_data.json')\ntrain_labels = pd.read_json('../input/ai-village-ctf/murderbots/train_labels.json')\ntest_data = pd.read_json('../input/ai-village-ctf/murderbots/test_data.json')\n\nmodel = GaussianNB(priors=None, var_smoothing=2e-09)\nmodel.fit(train_data, train_labels)\nproba = model.predict_proba(test_data)[:,1]\n\nthreshold = 0.99\nthreshold_step = 0.005\n\nnp.where(proba > threshold)\n\nfor i in range(500):\n    select = np.where(proba > threshold)\n    if len(select[0]) >= 10:\n        break\n    else:\n        threshold -= threshold_step\n\nsolution = ''\n\nfor i in range(50):\n    if i in select[0]:\n        solution += '1'\n    else:\n        solution += '0'\n\nprint(solution)","metadata":{"execution":{"iopub.status.busy":"2022-09-12T00:08:28.580989Z","iopub.execute_input":"2022-09-12T00:08:28.581667Z","iopub.status.idle":"2022-09-12T00:08:28.629573Z","shell.execute_reply.started":"2022-09-12T00:08:28.581633Z","shell.execute_reply":"2022-09-12T00:08:28.628108Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Submission Helper\n\nf = solution # length == 50\ntry:\n    #r = requests.post(\"http://murderbot.fly.dev:5000/score\", json=json.dumps({\"submission\": f, 'challenge_id':'murderbots'}))\n    r = requests.post(\"http://murderbot.fly.dev:5000/score\", json=json.dumps({\"submission\": solution, 'challenge_id':'murderbots'}))\n    print(r.text)\nexcept requests.exceptions.ConnectionError:\n    print(\"Connection problems. Contact the CTF organizers.\")","metadata":{"execution":{"iopub.status.busy":"2022-09-12T00:08:28.631946Z","iopub.execute_input":"2022-09-12T00:08:28.632294Z","iopub.status.idle":"2022-09-12T00:08:29.149678Z","shell.execute_reply.started":"2022-09-12T00:08:28.632262Z","shell.execute_reply":"2022-09-12T00:08:29.148275Z"},"trusted":true},"execution_count":null,"outputs":[]}]}