{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":22559,"databundleVersionId":1923081,"sourceType":"competition"}],"dockerImageVersionId":30786,"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\nimport glob\nimport os\n# for dirname, _, filenames in os.walk('/kaggle/input'):\n#     for filename in filenames:\n#         print(os.path.join(dirname, filename))\n\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","execution":{"iopub.status.busy":"2024-11-10T02:46:45.212019Z","iopub.execute_input":"2024-11-10T02:46:45.213389Z","iopub.status.idle":"2024-11-10T02:46:46.456415Z","shell.execute_reply.started":"2024-11-10T02:46:45.213302Z","shell.execute_reply":"2024-11-10T02:46:46.455405Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pickle\nimport gc \nimport random\n\n# 可視化\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom PIL import Image, ImageOps\nfrom skimage import io\nfrom skimage.color import rgba2rgb, rgb2xyz\nfrom tqdm import tqdm\nfrom dataclasses import dataclass\nfrom math import floor, ceil\n\n# 前処理\nfrom sklearn.preprocessing import StandardScaler, MinMaxScaler, LabelEncoder, OneHotEncoder\n\n# バリデーション\nfrom sklearn.model_selection import train_test_split, KFold, StratifiedKFold\n\n# 評価指標\nfrom sklearn.metrics import accuracy_score, roc_auc_score, confusion_matrix\n\n# モデリング: lightgbm\n# import lightgbm as lgb\n# from lightgbm import early_stopping\nimport warnings\nwarnings.filterwarnings(\"ignore\")\n\nmycolors = [\"#797D62\", \"#9B9B7A\", \"#D9AE94\", \"#FFCB69\", \"#D08C60\", \"#997B66\"]","metadata":{"execution":{"iopub.status.busy":"2024-11-10T02:46:46.458840Z","iopub.execute_input":"2024-11-10T02:46:46.459479Z","iopub.status.idle":"2024-11-10T02:46:48.914205Z","shell.execute_reply.started":"2024-11-10T02:46:46.459425Z","shell.execute_reply":"2024-11-10T02:46:48.912837Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"base = \"/kaggle/input/indoor-location-navigation/\"\npath_test=f'{base}/test'\npath_train=f'{base}/train'\n\n# with warnings.catch_warnings():\n#     warnings.simplefilter(\"ignore\")\n#     df_test = pd.read_csv(path_test,delimiter='\\t',comment=\"#\",header=None,on_bad_lines=\"warn\")\n#     df_train = pd.read_csv(path_train,delimiter='\\t',comment=\"#\",header=None,on_bad_lines=\"warn\")\n\n# 1行ずつデータを引っ張ってきて1行ずつそれぞれのdfにいれるような形で作るといい。\n# 目的変数と説明変数でそれぞれ。\n# 目的変数と説明変数をくっつけるときにタイムスタンプをどうするか。時間が近いもので補完するとかなど。\n# 公式でどういうFormatで書かれているかをみる\n# ベースラインを使うときにはWifiとWaypointを組み合わせてベースラインを作ればいい\n# データセットの仕方は苦しんだ後はDisscusionをみにいけばいい。\n# ","metadata":{"execution":{"iopub.status.busy":"2024-11-10T02:46:48.916361Z","iopub.execute_input":"2024-11-10T02:46:48.917055Z","iopub.status.idle":"2024-11-10T02:46:48.924452Z","shell.execute_reply.started":"2024-11-10T02:46:48.916997Z","shell.execute_reply":"2024-11-10T02:46:48.922309Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# import os\n# import shutil\n\n# # OUTPUTディレクトリのパス\n# output_dir = \"/kaggle/working\"\n\n# # OUTPUTディレクトリ内のファイルとサブディレクトリを全て削除\n# for filename in os.listdir(output_dir):\n#     file_path = os.path.join(output_dir, filename)\n#     try:\n#         # ファイルの場合は削除\n#         if os.path.isfile(file_path) or os.path.islink(file_path):\n#             os.unlink(file_path)\n#         # ディレクトリの場合は削除\n#         elif os.path.isdir(file_path):\n#             shutil.rmtree(file_path)\n#     except Exception as e:\n#         print(f\"Failed to delete {file_path}. Reason: {e}\")\n\n# print(\"OUTPUTフォルダの内容を削除しました。\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-10T02:46:48.927758Z","iopub.execute_input":"2024-11-10T02:46:48.928160Z","iopub.status.idle":"2024-11-10T02:46:48.943716Z","shell.execute_reply.started":"2024-11-10T02:46:48.928119Z","shell.execute_reply":"2024-11-10T02:46:48.942400Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def get_output_folder_size():\n    output_folder = '/kaggle/working'\n    total_size = 0\n    for dirpath, dirnames, filenames in os.walk(output_folder):\n        for f in filenames:\n            fp = os.path.join(dirpath, f)\n            total_size += os.path.getsize(fp)\n    return total_size / (1024**3)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-10T02:46:48.945229Z","iopub.execute_input":"2024-11-10T02:46:48.945665Z","iopub.status.idle":"2024-11-10T02:46:48.956722Z","shell.execute_reply.started":"2024-11-10T02:46:48.945625Z","shell.execute_reply":"2024-11-10T02:46:48.955452Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 全パス\nall_files = glob.glob(os.path.join(path_train, '*', '*', '*.txt'))\nlen(all_files)\n\nprint(f\"シャッフル前:{len(all_files)}\")\nrandom.seed(123)\nrandom.shuffle(all_files)\n\nall_files = all_files[:5385] #総量の20%\nprint(f\"シャッフル後:{len(all_files)}\")\n\n# リスト\nfiltered_waypoint = []\nfiltered_wifi = []\nfiltered_ACCELEROMETER = []\nfiltered_MAGNETIC_FIELD = []\nfiltered_GYROSCOPE = []\nfiltered_ROTATION_VECTOR = []\nfiltered_ACCELEROMETER_UNCALIBRATED = []\nfiltered_MAGNETIC_FIELD_UNCALIBRATED = []\nfiltered_GYROSCOPE_UNCALIBRATED = []\nfiltered_BEACON = []\n\n# バッチ処理の設定\nbatch_size = 1077 #5385を5分割する。そのうちの1つを検証用にすればいいのでは？\nmax_output_size_gb = 15\nnum_batches = len(all_files) // batch_size\n\nfor batch_num in range(num_batches):\n    print(f\"Processing batch Start: {batch_num}\")\n\n    current_size = get_output_folder_size()\n    if current_size >= max_output_size_gb:\n        print(\"Output folder size exceeded 15GB. Stopping output.\")\n        break\n    \n    # バッチ内のファイルを取得\n    batch_files = all_files[batch_num * batch_size : (batch_num + 1) * batch_size]\n    batch_data = []\n\n    for file_path in batch_files:\n        parts = file_path.split(os.sep)\n        a_level = parts[-3]\n        b_level = parts[-2]\n        file_name = os.path.splitext(parts[-1])[0] \n    # #全部やると多いからお試し用で読み込み数を制限\n    # if a_level_count >= 5:\n    #     break\n    # else:\n    #     a_level_count += 1\n\n        with open(file_path, 'r') as file:\n            for line in file:\n\n                data = line.strip().split('\\t')\n            \n            # 2列目のTYPEで分岐\n                if len(data) > 1 and data[1] == \"TYPE_WAYPOINT\":\n                    max_columns_raw = 4\n                    max_columns = max_columns_raw + 3\n                    if len(data) > max_columns_raw:\n                        continue\n                    data.insert(0, file_name)\n                    data.insert(0, b_level)\n                    data.insert(0, a_level)\n                    #カラム数がずれている場合に9999で埋める\n                    if len(data) < max_columns:\n                        data += [9999] * (max_columns - len(data))\n                    filtered_waypoint.append(data)\n                elif len(data) > 1 and data[1] == \"TYPE_WIFI\":\n                    max_columns_raw = 7\n                    max_columns = max_columns_raw + 3\n                    if len(data) > max_columns_raw:\n                        continue\n                    data.insert(0, file_name)\n                    data.insert(0, b_level)\n                    data.insert(0, a_level)\n                    #カラム数がずれている場合に9999で埋める\n                    if len(data) < max_columns:\n                        data += [9999] * (max_columns - len(data))\n                    filtered_wifi.append(data)\n                elif len(data) > 1 and data[1] == \"TYPE_ACCELEROMETER\":\n                    max_columns_raw = 6\n                    max_columns = max_columns_raw + 3\n                    if len(data) > max_columns_raw:\n                        continue\n                    data.insert(0, file_name)\n                    data.insert(0, b_level)\n                    data.insert(0, a_level)\n                    #カラム数がずれている場合に9999で埋める\n                    if len(data) < max_columns:\n                        data += [9999] * (max_columns - len(data))\n                    filtered_ACCELEROMETER.append(data)\n                elif len(data) > 1 and data[1] == \"TYPE_MAGNETIC_FIELD\":\n                    max_columns_raw = 6\n                    max_columns = max_columns_raw + 3\n                    if len(data) > max_columns_raw:\n                        continue\n                    data.insert(0, file_name)\n                    data.insert(0, b_level)\n                    data.insert(0, a_level)\n                    #カラム数がずれている場合に9999で埋める\n                    if len(data) < max_columns:\n                        data += [9999] * (max_columns - len(data))\n                    filtered_MAGNETIC_FIELD.append(data)\n                elif len(data) > 1 and data[1] == \"TYPE_GYROSCOPE\":\n                    max_columns_raw = 6\n                    max_columns = max_columns_raw + 3\n                    if len(data) > max_columns_raw:\n                        continue\n                    data.insert(0, file_name)\n                    data.insert(0, b_level)\n                    data.insert(0, a_level)\n                    #カラム数がずれている場合に9999で埋める\n                    if len(data) < max_columns:\n                        data += [9999] * (max_columns - len(data))\n                    filtered_GYROSCOPE.append(data)\n                elif len(data) > 1 and data[1] == \"TYPE_ROTATION_VECTOR\":\n                    max_columns_raw = 6\n                    max_columns = max_columns_raw + 3\n                    if len(data) > max_columns_raw:\n                        continue\n                    data.insert(0, file_name)\n                    data.insert(0, b_level)\n                    data.insert(0, a_level)\n                    #カラム数がずれている場合に9999で埋める\n                    if len(data) < max_columns:\n                        data += [9999] * (max_columns - len(data))\n                    filtered_ROTATION_VECTOR.append(data)\n                elif len(data) > 1 and data[1] == \"TYPE_ACCELEROMETER_UNCALIBRATED\":\n                    max_columns_raw = 9\n                    max_columns = max_columns_raw + 3\n                    if len(data) > max_columns_raw:\n                        continue\n                    data.insert(0, file_name)\n                    data.insert(0, b_level)\n                    data.insert(0, a_level)\n                    #カラム数がずれている場合に9999で埋める\n                    if len(data) < max_columns:\n                        data += [9999] * (max_columns - len(data))\n                    filtered_ACCELEROMETER_UNCALIBRATED.append(data)\n                elif len(data) > 1 and data[1] == \"TYPE_MAGNETIC_FIELD_UNCALIBRATED\":\n                    max_columns_raw = 9\n                    max_columns = max_columns_raw + 3\n                    if len(data) > max_columns_raw:\n                        continue\n                    data.insert(0, file_name)\n                    data.insert(0, b_level)\n                    data.insert(0, a_level)\n                    #カラム数がずれている場合に9999で埋める\n                    if len(data) < max_columns:\n                        data += [9999] * (max_columns - len(data))\n                    filtered_MAGNETIC_FIELD_UNCALIBRATED.append(data)\n                elif len(data) > 1 and data[1] == \"TYPE_GYROSCOPE_UNCALIBRATED\":\n                    max_columns_raw = 9\n                    max_columns = max_columns_raw + 3\n                    if len(data) > max_columns_raw:\n                        continue\n                    data.insert(0, file_name)\n                    data.insert(0, b_level)\n                    data.insert(0, a_level)\n                    #カラム数がずれている場合に9999で埋める\n                    if len(data) < max_columns:\n                        data += [9999] * (max_columns - len(data))\n                    filtered_GYROSCOPE_UNCALIBRATED.append(data)\n                elif len(data) > 1 and data[1] == \"TYPE_BEACON\":\n                    max_columns_raw = 10\n                    max_columns = max_columns_raw + 3\n                    if len(data) > max_columns_raw:\n                        continue\n                    data.insert(0, file_name)\n                    data.insert(0, b_level)\n                    data.insert(0, a_level)\n                    #カラム数がずれている場合に9999で埋める\n                    if len(data) < max_columns:\n                        data += [9999] * (max_columns - len(data))\n                    filtered_BEACON.append(data)\n\n    waypoint_df = pd.DataFrame(filtered_waypoint, columns=['ALevel', 'BLevel', 'FileName', 'Time', 'Type','x', 'y'])\n    wifi_df = pd.DataFrame(filtered_wifi, columns=['ALevel', 'BLevel', 'FileName', 'Time', 'Type', 'ssid', 'bssid','rssi', 'freq', 'last_time'])\n    ACCELEROMETER_df = pd.DataFrame(filtered_ACCELEROMETER, columns=['ALevel', 'BLevel', 'FileName', 'Time', 'Type', 'x', 'y','z', 'acc'])\n    MAGNETIC_FIELD_df = pd.DataFrame(filtered_MAGNETIC_FIELD, columns=['ALevel', 'BLevel', 'FileName', 'Time', 'Type', 'x', 'y','z', 'acc'])\n    GYROSCOPE_df = pd.DataFrame(filtered_GYROSCOPE, columns=['ALevel', 'BLevel', 'FileName', 'Time', 'Type', 'x', 'y','z', 'acc'])\n    ROTATION_VECTOR_df = pd.DataFrame(filtered_ROTATION_VECTOR, columns=['ALevel', 'BLevel', 'FileName', 'Time', 'Type', 'x', 'y','z', 'acc'])\n    ACCELEROMETER_UNCALIBRATED_df = pd.DataFrame(filtered_ACCELEROMETER_UNCALIBRATED, columns=['ALevel', 'BLevel', 'FileName', 'Time', 'Type', 'x', 'y','z','x_hosei','y_hosei','z_hosei', 'acc'])\n    MAGNETIC_FIELD_UNCALIBRATED_df = pd.DataFrame(filtered_MAGNETIC_FIELD_UNCALIBRATED, columns=['ALevel', 'BLevel', 'FileName', 'Time', 'Type', 'x', 'y','z','x_hosei','y_hosei','z_hosei', 'acc'])\n    GYROSCOPE_UNCALIBRATED_df = pd.DataFrame(filtered_GYROSCOPE_UNCALIBRATED, columns=['ALevel', 'BLevel', 'FileName', 'Time', 'Type', 'x', 'y','z','x_hosei','y_hosei','z_hosei', 'acc'])\n    BEACON_df = pd.DataFrame(filtered_BEACON, columns=['ALevel', 'BLevel', 'FileName', 'Time', 'Type', 'uuid', 'majorid','minorid', 'txpower', 'rssi', 'distance', 'macadd', 'same with Unix time padding data'])\n\n    #CSV\n    waypoint_file = f\"waypoint_batch_{batch_num + 1}.csv\"\n    wifi_file = f\"wifi_batch_{batch_num + 1}.csv\"\n    ACCELEROMETER_file = f\"ACCELEROMETER_batch_{batch_num + 1}.csv\"\n    MAGNETIC_file = f\"MAGNETIC_batch_{batch_num + 1}.csv\"\n    GYROSCOPE_file = f\"GYROSCOPE_batch_{batch_num + 1}.csv\"\n    ROTATION_VECTOR_file = f\"ROTATION_VECTOR_batch_{batch_num + 1}.csv\"\n    ACCELEROMETER_UNCALIBRATED_file = f\"ACCELEROMETER_UNCALIBRATED_batch_{batch_num + 1}.csv\"\n    MAGNETIC_FIELD_UNCALIBRATED_file = f\"MAGNETIC_FIELD_UNCALIBRATED_batch_{batch_num + 1}.csv\"\n    GYROSCOPE_UNCALIBRATED_file = f\"GYROSCOPE_UNCALIBRATED_batch_{batch_num + 1}.csv\"\n    BEACON_file = f\"BEACON_df_batch_{batch_num + 1}.csv\"\n    \n    print(f\"Processing csv out Start: {batch_num}\")\n    waypoint_df.to_csv(waypoint_file, index=False, encoding=\"utf-8\")\n    wifi_df.to_csv(wifi_file, index=False, encoding=\"utf-8\")\n    ACCELEROMETER_df.to_csv(ACCELEROMETER_file, index=False, encoding=\"utf-8\")\n    MAGNETIC_FIELD_df.to_csv(MAGNETIC_file, index=False, encoding=\"utf-8\")\n    GYROSCOPE_df.to_csv(GYROSCOPE_file, index=False, encoding=\"utf-8\")\n    ROTATION_VECTOR_df.to_csv(ROTATION_VECTOR_file, index=False, encoding=\"utf-8\")\n    ACCELEROMETER_UNCALIBRATED_df.to_csv(ACCELEROMETER_UNCALIBRATED_file, index=False, encoding=\"utf-8\")\n    MAGNETIC_FIELD_UNCALIBRATED_df.to_csv(MAGNETIC_FIELD_UNCALIBRATED_file, index=False, encoding=\"utf-8\")\n    GYROSCOPE_UNCALIBRATED_df.to_csv(GYROSCOPE_UNCALIBRATED_file, index=False, encoding=\"utf-8\")\n    BEACON_df.to_csv(BEACON_file, index=False, encoding=\"utf-8\")\n\n    #リストの初期化\n    filtered_waypoint = []\n    filtered_wifi = []\n    filtered_ACCELEROMETER = []\n    filtered_MAGNETIC_FIELD = []\n    filtered_GYROSCOPE = []\n    filtered_ROTATION_VECTOR = []\n    filtered_ACCELEROMETER_UNCALIBRATED = []\n    filtered_MAGNETIC_FIELD_UNCALIBRATED = []\n    filtered_GYROSCOPE_UNCALIBRATED = []\n    filtered_BEACON = []\n    gc.collect()\n    print(f\"Processing END: {batch_num}\")\n\n# print(f\"Total rows added: {len(waypoint_df)},{len(wifi_df)}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-10T02:46:48.958794Z","iopub.execute_input":"2024-11-10T02:46:48.959735Z","iopub.status.idle":"2024-11-10T03:32:10.782697Z","shell.execute_reply.started":"2024-11-10T02:46:48.959667Z","shell.execute_reply":"2024-11-10T03:32:10.781276Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# print(waypoint_df)\n# print('~~~'*20)\n# print(wifi_df)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-10T03:32:10.785209Z","iopub.execute_input":"2024-11-10T03:32:10.785613Z","iopub.status.idle":"2024-11-10T03:32:10.790837Z","shell.execute_reply.started":"2024-11-10T03:32:10.785571Z","shell.execute_reply":"2024-11-10T03:32:10.789531Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# #CSV\n# waypoint_df.to_csv(\"/kaggle/working/waypoint_df.csv\", index=False, encoding=\"utf-8\")\n# wifi_df.to_csv(\"/kaggle/working/wifi_df.csv\", index=False, encoding=\"utf-8\")\n# ACCELEROMETER_df.to_csv(\"/kaggle/working/ACCELEROMETER_df.csv\", index=False, encoding=\"utf-8\")\n# MAGNETIC_FIELD_df.to_csv(\"/kaggle/working/MAGNETIC_FIELD_df.csv\", index=False, encoding=\"utf-8\")\n# GYROSCOPE_df.to_csv(\"/kaggle/working/GYROSCOPE_df.csv\", index=False, encoding=\"utf-8\")\n# ROTATION_VECTOR_df.to_csv(\"/kaggle/working/ROTATION_VECTOR_df.csv\", index=False, encoding=\"utf-8\")\n# ACCELEROMETER_UNCALIBRATED_df.to_csv(\"/kaggle/working/ACCELEROMETER_UNCALIBRATED_df.csv\", index=False, encoding=\"utf-8\")\n# MAGNETIC_FIELD_UNCALIBRATED_df.to_csv(\"/kaggle/working/MAGNETIC_FIELD_UNCALIBRATED_df.csv\", index=False, encoding=\"utf-8\")\n# GYROSCOPE_UNCALIBRATED_df.to_csv(\"/kaggle/working/GYROSCOPE_UNCALIBRATED_df.csv\", index=False, encoding=\"utf-8\")\n# BEACON_df.to_csv(\"/kaggle/working/BEACON_df.csv\", index=False, encoding=\"utf-8\")\n#DF\n# waypoint_df.to_csv(\"/kaggle/working/waypoint_df\", index=False, encoding=\"utf-8\")\n# wifi_df.to_csv(\"/kaggle/working/wifi_df\", index=False, encoding=\"utf-8\")\n# ACCELEROMETER_df.to_csv(\"/kaggle/working/ACCELEROMETER_df\", index=False, encoding=\"utf-8\")\n# MAGNETIC_FIELD_df.to_csv(\"/kaggle/working/MAGNETIC_FIELD_df\", index=False, encoding=\"utf-8\")\n# GYROSCOPE_df.to_csv(\"/kaggle/working/GYROSCOPE_df\", index=False, encoding=\"utf-8\")\n# ACCELEROMETER_UNCALIBRATED_df.to_csv(\"/kaggle/working/ACCELEROMETER_UNCALIBRATED_df\", index=False, encoding=\"utf-8\")\n# MAGNETIC_FIELD_UNCALIBRATED_df.to_csv(\"/kaggle/working/MAGNETIC_FIELD_UNCALIBRATED_df\", index=False, encoding=\"utf-8\")\n# GYROSCOPE_UNCALIBRATED_df.to_csv(\"/kaggle/working/GYROSCOPE_UNCALIBRATED_df\", index=False, encoding=\"utf-8\")\n# BEACON_df.to_csv(\"/kaggle/working/BEACON_df\", index=False, encoding=\"utf-8\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-10T03:32:10.792408Z","iopub.execute_input":"2024-11-10T03:32:10.792883Z","iopub.status.idle":"2024-11-10T03:32:10.826136Z","shell.execute_reply.started":"2024-11-10T03:32:10.792771Z","shell.execute_reply":"2024-11-10T03:32:10.824994Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# サイトのMap情報を表示するコード\n# def show_site_png(site):\n#     site_path = f\"{base}/metadata/{site}/*/floor_image.png\"\n#     floor_paths = glob.glob(site_path)\n#     n = len(floor_paths)\n\n#     # Create the custom number of rows & columns\n#     ncols = [ceil(n / 3) if n > 3 else 3][0]\n#     nrows = [ceil(n / ncols) if n > 3 else 1][0]\n\n#     plt.figure(figsize=(16, 10))\n#     plt.suptitle(f\"Site no. '{site}'\", fontsize=18)\n\n#     # Plot image for each floor\n#     for k, floor in enumerate(floor_paths):\n#         plt.subplot(nrows, ncols, k+1)\n\n#         image = Image.open(floor)\n#         image = ImageOps.expand(image, border=15, fill=mycolors[5])\n\n#         plt.imshow(image)\n#         plt.axis(\"off\")\n#         title = floor.split(\"/\")[5]\n#         plt.title(title, fontsize=15)","metadata":{"execution":{"iopub.status.busy":"2024-11-10T03:32:10.827852Z","iopub.execute_input":"2024-11-10T03:32:10.828305Z","iopub.status.idle":"2024-11-10T03:32:10.844800Z","shell.execute_reply.started":"2024-11-10T03:32:10.828263Z","shell.execute_reply":"2024-11-10T03:32:10.843564Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# show_site_png(site='5cd56b64e2acfd2d33b592b3')","metadata":{"execution":{"iopub.status.busy":"2024-11-10T03:32:10.848727Z","iopub.execute_input":"2024-11-10T03:32:10.849218Z","iopub.status.idle":"2024-11-10T03:32:10.859381Z","shell.execute_reply.started":"2024-11-10T03:32:10.849175Z","shell.execute_reply":"2024-11-10T03:32:10.858386Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# import json\n# import geopandas as gpd\n# path_map=f'{base}/metadata/5a0546857ecc773753327266/B1/geojson_map.json'\n# path_finfo=f'{base}/metadata/5a0546857ecc773753327266/B1/floor_info.json'\n\n# gdf = gpd.read_file(path_map)\n\n# fig, ax = plt.subplots(figsize=(20, 20))\n# gdf.plot(ax=ax, color='lightblue', edgecolor='black')\n\n# # 建物名をプロット上に表示\n# for idx, row in gdf.iterrows():\n#     if 'name' in row and row['name']:\n#         x, y = row['geometry'].centroid.x, row['geometry'].centroid.y\n#         ax.text(x, y, row['name'], fontsize=6, ha='center', wrap=True)\n\n# plt.title(\"Building Map with Names\")\n# plt.xlabel(\"Longitude\")\n# plt.ylabel(\"Latitude\")\n# plt.show()","metadata":{"execution":{"iopub.status.busy":"2024-11-10T03:32:10.860575Z","iopub.execute_input":"2024-11-10T03:32:10.860961Z","iopub.status.idle":"2024-11-10T03:32:10.877644Z","shell.execute_reply.started":"2024-11-10T03:32:10.860921Z","shell.execute_reply":"2024-11-10T03:32:10.876494Z"},"trusted":true},"outputs":[],"execution_count":null}]}