{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9988,"databundleVersionId":868324,"sourceType":"competition"}],"dockerImageVersionId":30732,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# **Дослідницький аналіз даних для датасету Airbus Ship Detection**","metadata":{}},{"cell_type":"code","source":"import numpy as np \nimport pandas as pd \nimport tensorflow as tf\nimport seaborn as sns\nimport matplotlib\nimport matplotlib.pyplot as plt\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-07-14T20:02:20.073009Z","iopub.execute_input":"2024-07-14T20:02:20.074583Z","iopub.status.idle":"2024-07-14T20:02:20.081754Z","shell.execute_reply.started":"2024-07-14T20:02:20.074502Z","shell.execute_reply":"2024-07-14T20:02:20.079935Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('/kaggle/input/airbus-ship-detection/train_ship_segmentations_v2.csv')\ndf","metadata":{"execution":{"iopub.status.busy":"2024-07-14T20:02:20.084683Z","iopub.execute_input":"2024-07-14T20:02:20.085798Z","iopub.status.idle":"2024-07-14T20:02:21.318255Z","shell.execute_reply.started":"2024-07-14T20:02:20.085743Z","shell.execute_reply":"2024-07-14T20:02:21.317002Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Присутні рядки з однаковим ImageId та різними EncodedPixels. Можна зробити висновок, що зображення, що мають декілька кораблів розділені на різні рядки з однаковим ImageId та EncodedPixels для кожного корабля присутньому на зображенні\n","metadata":{}},{"cell_type":"code","source":"df.describe()","metadata":{"execution":{"iopub.status.busy":"2024-07-14T20:02:21.319707Z","iopub.execute_input":"2024-07-14T20:02:21.320072Z","iopub.status.idle":"2024-07-14T20:02:21.857802Z","shell.execute_reply.started":"2024-07-14T20:02:21.320044Z","shell.execute_reply":"2024-07-14T20:02:21.856407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2024-07-14T20:02:21.860980Z","iopub.execute_input":"2024-07-14T20:02:21.861448Z","iopub.status.idle":"2024-07-14T20:02:21.929474Z","shell.execute_reply.started":"2024-07-14T20:02:21.861409Z","shell.execute_reply":"2024-07-14T20:02:21.928150Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"num_images = df['ImageId'].nunique()\nnum_ships = df[df['EncodedPixels'].notnull()].shape[0]\nprint('total images: ', num_images)\nprint('total ships: ', num_ships)","metadata":{"execution":{"iopub.status.busy":"2024-07-14T20:02:21.931109Z","iopub.execute_input":"2024-07-14T20:02:21.932202Z","iopub.status.idle":"2024-07-14T20:02:22.035782Z","shell.execute_reply.started":"2024-07-14T20:02:21.932101Z","shell.execute_reply":"2024-07-14T20:02:22.034603Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Створення стовпця для маркування зображень з кораблями\ndf['has_ship'] = df['EncodedPixels'].notnull().astype(int)\n\n# Групування по зображенню, так як деякі зображення мають декілька кораблів\ngrouped_df = df.groupby('ImageId')['has_ship'].max().reset_index()\n\n# Гістограмма співвідношення зображень з кораблями та без них\nsns.countplot(x='has_ship', data=grouped_df)\nplt.xlabel('Has Ship')\nplt.ylabel('Count')\nplt.title('Distribution of Images with/without Ships')\nplt.show()\n\n# Підрахунок проценту зображень з кораблями\npercent_with_ship = grouped_df['has_ship'].mean() * 100\nprint(f\"Процент зображень з кораблями: {percent_with_ship:.2f}%\")","metadata":{"execution":{"iopub.status.busy":"2024-07-14T20:02:22.037315Z","iopub.execute_input":"2024-07-14T20:02:22.037692Z","iopub.status.idle":"2024-07-14T20:02:22.624570Z","shell.execute_reply.started":"2024-07-14T20:02:22.037664Z","shell.execute_reply":"2024-07-14T20:02:22.623249Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Спираючись на інформацію вище, можна побачити, що приблизно 78% зображень не має кораблів ","metadata":{}}]}