{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceType":"competition","sourceId":24800,"datasetId":1042002,"databundleVersionId":1831594}],"dockerImageVersionId":31286,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nfrom pathlib import Path\n\ncsv_path = Path(\"/kaggle/input/competitions/vinbigdata-chest-xray-abnormalities-detection/train.csv\")\ndf = pd.read_csv(csv_path)\n\ndf.head(), df.shape","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-03-03T14:34:25.549361Z","iopub.execute_input":"2026-03-03T14:34:25.549625Z","iopub.status.idle":"2026-03-03T14:34:27.179988Z","shell.execute_reply.started":"2026-03-03T14:34:25.549598Z","shell.execute_reply":"2026-03-03T14:34:27.178811Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# képszám osztályonként (legalább 1 annotáció az osztályból a képen)\nimg_counts = (\n    df.groupby(\"class_name\")[\"image_id\"]\n      .nunique()\n      .sort_values(ascending=False)\n      .rename(\"n_images\")\n)\n\n# annotációsorok száma osztályonként (ez kb. bbox/db, de \"No finding\"-nál nincs bbox)\nann_counts = (\n    df[\"class_name\"].value_counts()\n      .rename(\"n_rows\")\n)\n\nsummary = pd.concat([img_counts, ann_counts], axis=1).fillna(0).astype(int)\nsummary","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-03T14:34:27.182303Z","iopub.execute_input":"2026-03-03T14:34:27.182619Z","iopub.status.idle":"2026-03-03T14:34:27.240367Z","shell.execute_reply.started":"2026-03-03T14:34:27.182588Z","shell.execute_reply":"2026-03-03T14:34:27.239172Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"summary_no_nf = summary.drop(index=\"No finding\", errors=\"ignore\")\nsummary_no_nf","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-03T14:34:27.241462Z","iopub.execute_input":"2026-03-03T14:34:27.241729Z","iopub.status.idle":"2026-03-03T14:34:27.256383Z","shell.execute_reply.started":"2026-03-03T14:34:27.241707Z","shell.execute_reply":"2026-03-03T14:34:27.255152Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def images_for_class(class_name: str):\n    sub = df[df[\"class_name\"] == class_name]\n    ids = sub[\"image_id\"].dropna().unique()\n    return ids\n\n# példa:\ncls = \"Aortic enlargement\"  # írja át amire szeretné\nids = images_for_class(cls)\n\nprint(\"Class:\", cls)\nprint(\"N images:\", len(ids))\nprint(\"First 20 image_ids:\", ids[:20])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-03T14:34:27.257904Z","iopub.execute_input":"2026-03-03T14:34:27.258379Z","iopub.status.idle":"2026-03-03T14:34:27.297323Z","shell.execute_reply.started":"2026-03-03T14:34:27.258336Z","shell.execute_reply":"2026-03-03T14:34:27.296312Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"labels_per_image = (\n    df.groupby(\"image_id\")[\"class_name\"]\n      .nunique()\n      .sort_values(ascending=False)\n)\nlabels_per_image.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-03T14:34:27.298539Z","iopub.execute_input":"2026-03-03T14:34:27.298969Z","iopub.status.idle":"2026-03-03T14:34:27.353919Z","shell.execute_reply.started":"2026-03-03T14:34:27.298936Z","shell.execute_reply":"2026-03-03T14:34:27.353046Z"}},"outputs":[],"execution_count":null}]}