{"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 matplotlib.pyplot as plt\nimport seaborn as sns\nfrom sklearn.metrics import accuracy_score","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-10-14T01:50:01.241767Z","iopub.execute_input":"2023-10-14T01:50:01.242267Z","iopub.status.idle":"2023-10-14T01:50:01.248391Z","shell.execute_reply.started":"2023-10-14T01:50:01.24223Z","shell.execute_reply":"2023-10-14T01:50:01.246912Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv(\"../input/UBC-OCEAN/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-10-14T01:50:01.250318Z","iopub.execute_input":"2023-10-14T01:50:01.250688Z","iopub.status.idle":"2023-10-14T01:50:01.28534Z","shell.execute_reply.started":"2023-10-14T01:50:01.250659Z","shell.execute_reply":"2023-10-14T01:50:01.284528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train","metadata":{"execution":{"iopub.status.busy":"2023-10-14T01:50:01.250318Z","iopub.execute_input":"2023-10-14T01:50:01.250688Z","iopub.status.idle":"2023-10-14T01:50:01.28534Z","shell.execute_reply.started":"2023-10-14T01:50:01.250659Z","shell.execute_reply":"2023-10-14T01:50:01.284528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[train.is_tma].describe()","metadata":{"execution":{"iopub.status.busy":"2023-10-14T01:50:01.65789Z","iopub.execute_input":"2023-10-14T01:50:01.658472Z","iopub.status.idle":"2023-10-14T01:50:01.67763Z","shell.execute_reply.started":"2023-10-14T01:50:01.658427Z","shell.execute_reply":"2023-10-14T01:50:01.676156Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[~train.is_tma].describe()","metadata":{"execution":{"iopub.status.busy":"2023-10-14T01:50:01.679953Z","iopub.execute_input":"2023-10-14T01:50:01.68122Z","iopub.status.idle":"2023-10-14T01:50:01.701292Z","shell.execute_reply.started":"2023-10-14T01:50:01.681173Z","shell.execute_reply":"2023-10-14T01:50:01.699828Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Using a threshold value of around 5000 for both `image_width` and `image_height` seems to perfectly predict the value of `is_tma`.","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10, 8))\nsns.scatterplot(x='image_width', y='image_height', hue='is_tma', data=train)\nplt.title('Scatter Plot of image_width and image_height colored by is_tma')\nplt.xlabel('Image Width')\nplt.ylabel('Image Height')\nplt.legend(title='is_tma')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-10-14T01:50:01.287295Z","iopub.execute_input":"2023-10-14T01:50:01.28796Z","iopub.status.idle":"2023-10-14T01:50:01.656538Z","shell.execute_reply.started":"2023-10-14T01:50:01.287927Z","shell.execute_reply":"2023-10-14T01:50:01.655671Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From the above visualization, it can be inferred that `is_tma` can be perfectly predicted based on the values of `image_width` and `image_height`.","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def predict_is_tma(image_width, image_height, threshold=5000):\n    return (image_width < threshold) & (image_height < threshold)","metadata":{"execution":{"iopub.status.busy":"2023-10-14T01:50:01.702538Z","iopub.execute_input":"2023-10-14T01:50:01.702911Z","iopub.status.idle":"2023-10-14T01:50:01.710271Z","shell.execute_reply.started":"2023-10-14T01:50:01.702881Z","shell.execute_reply":"2023-10-14T01:50:01.709491Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predicted_is_tma = predict_is_tma(train['image_width'], train['image_height'], threshold=5000)\n\naccuracy = accuracy_score(train['is_tma'], predicted_is_tma)\nprint(f\"Accuracy: {accuracy}\")","metadata":{"execution":{"iopub.status.busy":"2023-10-14T02:01:56.836461Z","iopub.execute_input":"2023-10-14T02:01:56.836892Z","iopub.status.idle":"2023-10-14T02:01:57.176637Z","shell.execute_reply.started":"2023-10-14T02:01:56.83686Z","shell.execute_reply":"2023-10-14T02:01:57.175369Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}