{"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 numpy as np \nimport pandas as pd \nimport glob\nimport os\nimport matplotlib.pyplot as plt\nimport plotly.figure_factory as ff\nimport plotly.express as px\n\nimport plotly.graph_objects as go\nfrom plotly.offline import iplot","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-10-14T12:38:50.302217Z","iopub.execute_input":"2021-10-14T12:38:50.302583Z","iopub.status.idle":"2021-10-14T12:38:54.235703Z","shell.execute_reply.started":"2021-10-14T12:38:50.302488Z","shell.execute_reply":"2021-10-14T12:38:54.234532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_746 = pd.read_csv('../input/scoredata/0.746.csv')\nsub_674 = pd.read_csv('../input/tensorflow-score/submission.csv')\nsub_667 = pd.read_csv('../input/scoredata/0.667.csv')","metadata":{"execution":{"iopub.status.busy":"2021-10-14T12:40:50.09392Z","iopub.execute_input":"2021-10-14T12:40:50.094256Z","iopub.status.idle":"2021-10-14T12:40:50.121515Z","shell.execute_reply.started":"2021-10-14T12:40:50.094224Z","shell.execute_reply":"2021-10-14T12:40:50.120601Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_667","metadata":{"execution":{"iopub.status.busy":"2021-10-14T12:40:50.79292Z","iopub.execute_input":"2021-10-14T12:40:50.793642Z","iopub.status.idle":"2021-10-14T12:40:50.808094Z","shell.execute_reply.started":"2021-10-14T12:40:50.793596Z","shell.execute_reply":"2021-10-14T12:40:50.807449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"hist_data = [sub_746.MGMT_value, sub_674.MGMT_value, sub_667.MGMT_value]\ngroup_labels = ['sub_746', 'sub_674', 'sub_667']\n\nfig = ff.create_distplot(hist_data, group_labels, bin_size=.2, show_hist=False, show_rug=False)\n\nfig.update_layout(\n    width = 700,\n    height = 400\n)\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-14T12:40:51.398474Z","iopub.execute_input":"2021-10-14T12:40:51.399028Z","iopub.status.idle":"2021-10-14T12:40:51.434443Z","shell.execute_reply.started":"2021-10-14T12:40:51.398982Z","shell.execute_reply":"2021-10-14T12:40:51.433553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# dict for the dataframes and their names\ndfs = {\"sub_746\" : sub_746, \"sub_674\": sub_674, 'sub_667':sub_667}\n\n# plot the data\nfig = go.Figure()\nfor i in dfs:\n    fig = fig.add_trace(go.Scatter(x = dfs[i][\"BraTS21ID\"],\n                                   y = dfs[i][\"MGMT_value\"], \n                                   mode=\"markers\",\n                                   name = i))\n    fig = fig.add_trace(\n        go.Scatter(\n            x=[0, 1010],\n            y=[0.5, 0.5],\n            mode=\"lines\",\n            line=go.scatter.Line(color=\"gray\"),\n            showlegend=False)\n    )\n\nfig.update_layout(\n    width = 700,\n    height = 500\n)\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-14T12:40:52.733996Z","iopub.execute_input":"2021-10-14T12:40:52.734334Z","iopub.status.idle":"2021-10-14T12:40:52.758017Z","shell.execute_reply.started":"2021-10-14T12:40:52.734301Z","shell.execute_reply":"2021-10-14T12:40:52.757176Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_746['MGMT_value'].values.mean()","metadata":{"execution":{"iopub.status.busy":"2021-10-14T12:42:04.15249Z","iopub.execute_input":"2021-10-14T12:42:04.152797Z","iopub.status.idle":"2021-10-14T12:42:04.160151Z","shell.execute_reply.started":"2021-10-14T12:42:04.152755Z","shell.execute_reply":"2021-10-14T12:42:04.158917Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Finalsubmission = sub_746.copy()\nFinalsubmission['MGMT_value'] =\\\nsub_746['MGMT_value'].values*0.40+\\\nsub_674['MGMT_value'].values*0.30+\\\nsub_667['MGMT_value'].values*0.30","metadata":{"execution":{"iopub.status.busy":"2021-10-14T12:41:28.873284Z","iopub.execute_input":"2021-10-14T12:41:28.873618Z","iopub.status.idle":"2021-10-14T12:41:28.881994Z","shell.execute_reply.started":"2021-10-14T12:41:28.873582Z","shell.execute_reply":"2021-10-14T12:41:28.881398Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Finalsubmission['BraTS21ID'] = Finalsubmission['BraTS21ID'].apply(lambda x: str(x).zfill(5))\nFsubmission = Finalsubmission.set_index('BraTS21ID')\nFsubmissionDict = Fsubmission['MGMT_value'].to_dict()\n\nlistOfStudyPaths = glob.glob('../input/rsna-miccai-brain-tumor-radiogenomic-classification/test/*')\nlistOfStudies = [eachPath.split('/')[-1] for eachPath in listOfStudyPaths]\n\npredList = []\nfor eachStudy in listOfStudies:\n    if eachStudy not in FsubmissionDict:\n        predList.append('0.500')\n    else:\n        score = float(FsubmissionDict[eachStudy])\n        predList.append(score)\n        \nsubmission = pd.DataFrame({'BraTS21ID':listOfStudies,'MGMT_value':predList})","metadata":{"execution":{"iopub.status.busy":"2021-10-14T12:42:17.082219Z","iopub.execute_input":"2021-10-14T12:42:17.082515Z","iopub.status.idle":"2021-10-14T12:42:17.11112Z","shell.execute_reply.started":"2021-10-14T12:42:17.082486Z","shell.execute_reply":"2021-10-14T12:42:17.109997Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission=submission.sort_values(by=['BraTS21ID'], ascending=True)\nsubmission=submission.reset_index(drop=True)\nsubmission.head(5)","metadata":{"execution":{"iopub.status.busy":"2021-10-14T12:42:17.922987Z","iopub.execute_input":"2021-10-14T12:42:17.923369Z","iopub.status.idle":"2021-10-14T12:42:17.9399Z","shell.execute_reply.started":"2021-10-14T12:42:17.923335Z","shell.execute_reply":"2021-10-14T12:42:17.938744Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2021-10-14T12:42:18.874097Z","iopub.execute_input":"2021-10-14T12:42:18.874405Z","iopub.status.idle":"2021-10-14T12:42:18.884335Z","shell.execute_reply.started":"2021-10-14T12:42:18.874375Z","shell.execute_reply":"2021-10-14T12:42:18.883035Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}