{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":91451,"databundleVersionId":11223220,"sourceType":"competition"}],"dockerImageVersionId":30918,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-04-07T13:06:11.150153Z","iopub.execute_input":"2025-04-07T13:06:11.150656Z","iopub.status.idle":"2025-04-07T13:06:11.157219Z","shell.execute_reply.started":"2025-04-07T13:06:11.150586Z","shell.execute_reply":"2025-04-07T13:06:11.155591Z"},"_kg_hide-input":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#data viz\nimport matplotlib.pyplot as plt\nimport seaborn as sns \n\n# avoiding warnings\nimport warnings \nwarnings.filterwarnings('ignore')\n\nfrom PIL import Image\nimport cv2 \nimport tensorflow \nfrom tensorflow import keras \nfrom keras import Sequential\nfrom keras.layers import Conv2D , Dense , Softmax , Flatten , MaxPooling2D","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-07T13:06:15.002443Z","iopub.execute_input":"2025-04-07T13:06:15.002941Z","iopub.status.idle":"2025-04-07T13:06:15.010018Z","shell.execute_reply.started":"2025-04-07T13:06:15.002902Z","shell.execute_reply":"2025-04-07T13:06:15.008082Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Loading data ","metadata":{}},{"cell_type":"code","source":"metadata = pd.read_csv(\"/kaggle/input/animal-clef-2025/metadata.csv\")\nsubmission = pd.read_csv(\"/kaggle/input/animal-clef-2025/sample_submission.csv\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-07T13:06:36.174517Z","iopub.execute_input":"2025-04-07T13:06:36.174958Z","iopub.status.idle":"2025-04-07T13:06:36.231425Z","shell.execute_reply.started":"2025-04-07T13:06:36.174926Z","shell.execute_reply":"2025-04-07T13:06:36.229932Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data = {\n    \"metadata\": metadata,\n    \"submission_sample\": submission\n}\n\nfor name , df in data.items():\n    print(f\"--{name}--\")\n    print(f\"shape : {df.shape}\")\n    print(f\"features : {df.columns}\")\n    display(df.head())\n    print(\"\\n\" + \"__\"*42)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-07T13:06:39.116033Z","iopub.execute_input":"2025-04-07T13:06:39.116831Z","iopub.status.idle":"2025-04-07T13:06:39.150025Z","shell.execute_reply.started":"2025-04-07T13:06:39.116777Z","shell.execute_reply":"2025-04-07T13:06:39.148081Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# missing info \nmetadata.isnull().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-07T13:06:41.590565Z","iopub.execute_input":"2025-04-07T13:06:41.590966Z","iopub.status.idle":"2025-04-07T13:06:41.605485Z","shell.execute_reply.started":"2025-04-07T13:06:41.590934Z","shell.execute_reply":"2025-04-07T13:06:41.604333Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(\"__DataBase__\")\ndisplay(metadata[metadata[\"split\"] == \"database\"].isna().sum())\nprint(\"\\n\")\nprint(\"__Querry__\")\ndisplay(metadata[metadata[\"split\"] == \"query\"].isna().sum())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-07T13:06:41.742401Z","iopub.execute_input":"2025-04-07T13:06:41.742823Z","iopub.status.idle":"2025-04-07T13:06:41.769711Z","shell.execute_reply.started":"2025-04-07T13:06:41.742791Z","shell.execute_reply":"2025-04-07T13:06:41.768510Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#By Jocelyn Dumlao\n# Directories for each animal category\ndata_dirs = {    \n    \"SeaTurtlesD\": \"/kaggle/input/animal-clef-2025/images/SeaTurtleID2022/database/turtles-data/data/images/t001\",\n    \"SeaTurtlesQ\": \"/kaggle/input/animal-clef-2025/images/SeaTurtleID2022/query/images\",\n    \"LynxsD\": \"/kaggle/input/animal-clef-2025/images/LynxID2025/database\",\n    \"LynxsQ\": \"/kaggle/input/animal-clef-2025/images/LynxID2025/query\",\n    \"SalamandersD\": \"/kaggle/input/animal-clef-2025/images/SalamanderID2025/database/images\",\n    \"SalamandersQ\": \"/kaggle/input/animal-clef-2025/images/SalamanderID2025/query/images\"       \n}","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-07T13:06:43.612062Z","iopub.execute_input":"2025-04-07T13:06:43.612492Z","iopub.status.idle":"2025-04-07T13:06:43.618744Z","shell.execute_reply.started":"2025-04-07T13:06:43.612456Z","shell.execute_reply":"2025-04-07T13:06:43.616940Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# image preprocessing \n\ndef show_sample_images():\n    for label, dir_path in data_dirs.items():\n        if not os.path.exists(dir_path):\n            print(f\"Warning: Directory {dir_path} does not exist.\")\n            continue\n\n        # Load the first few images from the directory\n        sample_images = []\n        for root, _, files in os.walk(dir_path):\n            for img_name in files[:5]:  # Load 5 images for display\n                img_path = os.path.join(root, img_name)\n                if img_path.lower().endswith(('.JPG', '.jpg', '.jpeg')):\n                    img = cv2.imread(img_path)\n                    if img is not None:\n                        img = cv2.resize(img, (150, 150))\n                        sample_images.append(img)\n                    if len(sample_images) == 5:\n                        break\n            if len(sample_images) == 5:\n                break\n                \n        # Plot the images\n        plt.figure(figsize=(10, 10))\n        for i, img in enumerate(sample_images):\n            plt.subplot(1, 5, i + 1)\n            plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))\n            plt.axis('off')\n            plt.title(f\"{label}\")\n        plt.show()\n\n# Call the function to display images\nshow_sample_images()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-07T13:08:12.322949Z","iopub.execute_input":"2025-04-07T13:08:12.323440Z","iopub.status.idle":"2025-04-07T13:08:21.565867Z","shell.execute_reply.started":"2025-04-07T13:08:12.323402Z","shell.execute_reply":"2025-04-07T13:08:21.564658Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# to be continued... \n### shoutout to Jocelyn Dumlao I'm using his work to continue","metadata":{}},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}