{ "cells": [ { "cell_type": "markdown", "id": "781eee9c", "metadata": {}, "source": [ "## using pandas\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "70fc5658", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import os\n", "import json\n", "## column : file no 1~25\n", "\n", "# array 4X4\n", "# for i in range(rows):\n", "# for j in range(cols):\n", "# object_array[i,j] = np.zeros((4,4))\n", "\n", "\n", "data = np.zeros((20,25))\n", "\n", "\n", "\n", "## row : bottle_0, bottle_25 ... gt 0 25 --> 10 rows. \n", "\n", "categories = ['bottle2', 'lightbulb', 'lighter', 'eyeglasses', 'magnifying_glass', 'spray']\n", "\n", "category = categories[1]\n", "fill_rate = ['100', '75', '50', '25', '0']\n", "\n", "columns = [f'file_{i}' for i in range(1,26)]\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "id": "22195309", "metadata": {}, "source": [ "## Get transformation file " ] }, { "cell_type": "code", "execution_count": null, "id": "d3dcc164", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 2, "id": "86c0ea73", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "## Tmatrix FOlder access -> save in pandas\n", "robust_no = ['0','2','3','6']\n", "new_row_names = []\n", "# 결과를 저장할 딕셔너리를 카테고리별로 초기화합니다.\n", "grouped_files = {fill: [] for fill in fill_rate}\n", "\n", "for no in robust_no:\n", " \n", " ## get txt file\n", "\n", " ######################## We got the txt file list#################\n", " for fills in fill_rate:\n", " \n", " if no =='0':\n", " name = \"ICP\"\n", " elif no == '2':\n", " name = \"FAST ICP\"\n", " elif no =='3':\n", " name = \"Robust ICP\"\n", " else:\n", " name = \"Sparse ICP\"\n", "\n", " new_row_names.append(f\"{category}_{fills}_{name}\")\n", "\n", "df = pd.DataFrame(data, index=new_row_names, columns=columns, dtype=object)\n", "# 2. df.index에 새로운 이름 리스트를 바로 할당 object for array 4x4\n", "\n", "df.info" ] }, { "cell_type": "markdown", "id": "173149df", "metadata": {}, "source": [ "## RMSE function" ] }, { "cell_type": "code", "execution_count": 3, "id": "5334ae14", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "⚠️ 경고: './result3/result_3_100_1.txt' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n" ] } ], "source": [ "def RMSE(T_star, T):\n", " diff = T_star - T\n", " sq_norms = np.sum(diff**2, axis =1)\n", "\n", " r = np.sqrt(np.mean(sq_norms))\n", "\n", " return r\n", "\n", "## get T from Result Txt file\n", "def get_T(file_path):\n", "\n", " try:\n", " with open(file_path, 'r') as f:\n", " T_matrix = np.loadtxt(file_path)\n", " return T_matrix\n", " except FileNotFoundError:\n", " # try 블록에서 FileNotFoundError가 발생했을 때만 이 코드가 실행됩니다.\n", " print(f\"⚠️ 경고: '{file_path}' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\")\n", " return None # 파일이 없으므로 None을 반환\n", "\n", "\n", "\n", "\n", "def get_GT_T(file_path,data_name):\n", "\n", " try:\n", " with open(file_path, 'r') as f:\n", " loaded_data = json.load(f)\n", " noisy_data = loaded_data[data_name]\n", " T_matrix = noisy_data['matrix_world']\n", " np.array(T_matrix)\n", " return T_matrix\n", "\n", " except FileNotFoundError:\n", " # try 블록에서 FileNotFoundError가 발생했을 때만 이 코드가 실행됩니다.\n", " print(f\"⚠️ 경고: '{file_path}' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\")\n", " return None # 파일이 없으므로 None을 반환\n", "\n", " except KeyError as e:\n", " # try 블록에서 KeyError가 발생했을 때 실행됩니다. (e.g., 'matrix_world' 키가 없음)\n", " print(f\"⚠️ 경고: 파일 '{os.path.basename(file_path)}' 안에 필요한 키({e})가 없습니다.\")\n", " return None\n", " \n", " \n", "\n", "def compute_RMSE(gt_files):\n", " \n", " robust_no = ['0','2','3','6']\n", " \n", " for no in robust_no:\n", " if no =='0':\n", " name = \"ICP\"\n", " elif no == '2':\n", " name = \"FAST ICP\"\n", " elif no =='3':\n", " name = \"Robust ICP\"\n", " else:\n", " name = \"Sparse ICP\"\n", "\n", " for key, value_list in gt_files.items():\n", " rmse = []\n", " np.array(rmse)\n", " # get gt_T and noisy_T\n", " for value in value_list:\n", " profix = value.split('_')[1]\n", " gt_path = f\"./gt_raw/noisy_filtered_{key}_{profix}.json\"\n", " gt_name = f\"noisy_filtered_{key}_{profix}\"\n", "\n", " #### RESULT FOLDER PATH.\n", " result_path = f'./result{no}/result_{key}_{profix}.txt'\n", " icp_T = get_T(result_path)\n", " gt_T = get_GT_T(gt_path,gt_name)\n", " \n", " \n", "\n", " if (gt_T is None or icp_T is None):\n", " df.loc[f'{category}_{key}_{name}',f'file_{profix}'] = 0.0\n", "\n", " else:\n", " ## conpute rmse\n", " r = RMSE(gt_T, icp_T)\n", " \n", " df.loc[f'{category}_{key}_{name}',f'file_{profix}'] = r\n", "\n", "\n", "noisy_T = get_T(\"./result3/result_3_100_1.txt\")\n", "gt_T = get_GT_T(\"./gt/noisy_filtered_100_1.json\",\"noisy_filtered_100_1\")\n", "\n" ] }, { "cell_type": "markdown", "id": "587f5b2d", "metadata": {}, "source": [ "## Bring GT" ] }, { "cell_type": "code", "execution_count": 4, "id": "c4883f09", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "⚠️ 경고: './gt_raw/noisy_filtered_75_1.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_0_9.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_75_1.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_0_9.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_75_1.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_0_9.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_75_1.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_0_9.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", " file_1 file_2 file_3 file_4 file_5 file_6 file_7 file_8 file_9 file_10 file_11 file_12 file_13 file_14 file_15 file_16 file_17 file_18 file_19 file_20 file_21 file_22 file_23 file_24 file_25 mean_Val\n", "lightbulb_100_ICP 103.98447 104.565353 109.818912 107.240433 106.78074 107.061836 103.506492 96.975858 38.905718 34.743611 45.630022 12.332753 11.745771 13.350829 13.042864 14.351614 13.834044 14.051612 13.570112 13.979531 0.0 0.0 0.0 0.0 0.0 53.973629\n", "lightbulb_75_ICP 0.0 52.302238 83.250963 102.904808 106.562496 112.206058 111.43725 104.932135 89.953663 71.745028 33.891212 8.607876 13.091517 11.538156 12.406693 12.896077 8.602728 7.361024 10.180717 9.915981 0.0 0.0 0.0 0.0 0.0 50.725612\n", "lightbulb_50_ICP 113.13122 113.692223 112.735607 104.421379 101.188747 54.861169 61.130873 101.7967 108.469629 110.270757 106.106512 9.824989 12.517988 14.214799 13.292146 11.522909 13.605216 14.656726 14.853134 14.169484 0.0 0.0 0.0 0.0 0.0 60.323110\n", "lightbulb_25_ICP 112.191236 112.346354 113.124372 110.304337 104.219034 82.676305 44.830521 103.151362 108.27043 111.99015 111.272516 11.507546 13.049302 14.189969 10.77711 8.797878 13.377637 11.447832 13.629581 13.947722 0.0 0.0 0.0 0.0 0.0 61.255060\n", "lightbulb_0_ICP 109.415136 109.685456 117.440993 119.708833 120.270167 119.873045 120.981727 118.945298 0.0 70.582195 117.326187 157.522821 152.809831 103.048911 157.05479 102.294857 158.350918 103.403266 161.672922 159.961013 119.650388 120.283269 79.351446 0.0 0.0 122.710612\n", "lightbulb_100_FAST ICP 104.035583 104.635462 109.824508 107.196339 106.807446 107.145793 103.558118 97.06873 41.346621 36.813222 45.653219 12.330299 11.742075 13.340981 13.035206 14.353184 13.860245 14.045991 13.570413 13.979327 0.0 0.0 0.0 0.0 0.0 54.217138\n", "lightbulb_75_FAST ICP 0.0 52.207646 92.523859 102.880223 106.669757 112.181805 111.412737 104.932667 95.458434 71.756326 44.621859 8.625912 13.085044 11.53846 12.414036 12.903166 8.641926 7.365058 10.194541 9.899811 0.0 0.0 0.0 0.0 0.0 52.069119\n", "lightbulb_50_FAST ICP 113.230928 113.684427 111.707186 104.432407 101.206555 54.764861 61.130778 101.799637 108.469629 110.159112 105.704763 9.861285 12.531409 14.237861 13.309401 11.524188 13.616516 14.608723 14.897899 14.200284 0.0 0.0 0.0 0.0 0.0 60.253892\n", "lightbulb_25_FAST ICP 112.217262 112.400942 113.150651 19.865874 104.264638 82.730436 44.877268 103.144409 108.291652 111.990024 111.325549 11.488449 12.881126 14.195493 10.778225 8.807527 13.400508 11.484493 13.599075 13.940525 0.0 0.0 0.0 0.0 0.0 56.741706\n", "lightbulb_0_FAST ICP 109.457035 109.745744 117.407852 119.704853 120.232133 119.870854 120.973994 119.054922 0.0 70.151056 117.388946 157.524266 148.929811 102.936934 92.278907 102.286628 158.372504 103.350994 161.668309 159.813477 119.640495 34.211878 79.407981 0.0 0.0 115.654981\n", "lightbulb_100_Robust ICP 100.656553 100.265772 112.031006 112.095672 108.695883 93.246246 90.690985 83.059558 30.852626 22.604074 34.335439 2.804439 2.136346 2.844818 2.274384 2.040661 2.516029 2.72491 2.080608 2.012554 0.0 0.0 0.0 0.0 0.0 45.498428\n", "lightbulb_75_Robust ICP 0.0 44.409336 74.2255 90.365606 111.334952 111.333646 112.268981 100.980737 81.97706 61.777594 37.228097 1.924535 2.117269 2.080452 1.916491 2.190268 2.404712 3.478067 1.854583 1.611274 0.0 0.0 0.0 0.0 0.0 44.498903\n", "lightbulb_50_Robust ICP 112.188085 112.813444 112.251775 100.313877 87.889018 76.085361 1.173045 82.535445 111.379307 111.986331 111.558323 2.46845 2.42472 3.260555 1.431749 1.752413 1.737649 1.699779 1.770173 1.85551 0.0 0.0 0.0 0.0 0.0 51.928750\n", "lightbulb_25_Robust ICP 112.183205 111.819097 112.070231 4.601354 93.02836 80.797439 68.275646 97.402529 113.493377 112.485894 111.83982 3.944205 1.941063 1.72179 2.1447 2.700865 3.007329 2.526044 2.52136 3.651088 0.0 0.0 0.0 0.0 0.0 52.107770\n", "lightbulb_0_Robust ICP 141.500546 141.791352 129.967436 111.885463 112.142252 111.639716 132.501379 62.237965 0.0 77.830141 138.339977 151.829302 146.118296 95.186908 108.414518 96.108852 152.478053 107.630745 154.844619 152.870221 131.165472 139.326725 81.392398 0.0 0.0 121.691015\n", "lightbulb_100_Sparse ICP 90.700462 91.900485 108.008969 107.551359 99.033223 94.249693 78.442598 78.73422 57.989718 54.073644 63.75587 17.205612 16.85667 14.552057 16.356058 10.23808 11.839222 8.803319 12.77988 12.340294 0.0 0.0 0.0 0.0 0.0 52.270571\n", "lightbulb_75_Sparse ICP 0.0 70.939789 81.208288 87.52666 98.027725 108.576385 109.05019 98.077001 84.005557 81.306692 49.211489 15.64117 13.350377 15.402829 15.8654 15.971973 20.067033 20.197904 14.983979 19.787337 0.0 0.0 0.0 0.0 0.0 53.641988\n", "lightbulb_50_Sparse ICP 108.898934 109.432985 108.397308 103.50428 81.367205 60.489969 81.810123 79.575695 108.109763 108.619567 99.862084 13.879029 10.557673 8.525973 9.765928 12.758249 6.080241 1.523862 1.94761 1.730347 0.0 0.0 0.0 0.0 0.0 55.841841\n", "lightbulb_25_Sparse ICP 108.787752 109.174225 109.550695 109.617117 97.302117 85.187885 68.785826 94.114236 109.076674 109.682342 108.142645 5.123658 3.490953 6.681561 1.950736 2.777171 2.561626 2.567981 2.853046 4.211883 0.0 0.0 0.0 0.0 0.0 57.082006\n", "lightbulb_0_Sparse ICP 114.543432 119.966806 113.633685 124.355348 122.135718 117.8494 121.209017 123.209265 0.0 65.11228 115.290516 156.626871 152.022722 104.170831 94.509555 99.512119 156.970963 99.474232 161.32802 158.412887 119.293342 122.112083 53.427143 0.0 0.0 118.871192\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/tmp/ipykernel_290856/3042233176.py:18: FutureWarning: Downcasting behavior in `replace` is deprecated and will be removed in a future version. To retain the old behavior, explicitly call `result.infer_objects(copy=False)`. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`\n", " df['mean_Val'] = df.replace(0, np.nan).mean(axis=1)\n" ] } ], "source": [ "json_path = \"ply_files.json\"\n", "try: \n", " with open(json_path, \"r\", encoding=\"utf-8\") as f:\n", " gt_files = json.load(f)\n", "except FileNotFoundError:\n", " print(f\"오류: '{json_path}' 파일을 찾을 수 없습니다. 먼저 파일 분류 코드를 실행해 주세요.\")\n", " exit() # 파일이 없으면 프로그램 종료\n", "\n", "\n", "\n", "### get \n", "\n", "\n", "\n", "compute_RMSE(gt_files)\n", "\n", "##get mean value\n", "df['mean_Val'] = df.replace(0, np.nan).mean(axis=1)\n", "\n", "\n", "\n", "# 모든 행/열을 전부 보여줌\n", "pd.set_option('display.max_rows', None) # 행 전체 출력\n", "pd.set_option('display.max_columns', None) # 열 전체 출력\n", "\n", "# 각 열의 너비 제한 해제 (긴 문자열도 잘리지 않음)\n", "pd.set_option('display.max_colwidth', None)\n", "\n", "# 화면 너비에 따라 줄바꿈을 할지 말지\n", "pd.set_option('display.width', None) # None이면 자동으로 콘솔 너비를 사용\n", "pd.set_option('display.expand_frame_repr', False) # True면 줄바꿈 허용, False면 한 줄로 출력 시도\n", "\n", "# 예: DataFrame 출력\n", "print(df)\n", " \n", "\n", "\n" ] }, { "cell_type": "markdown", "id": "7493fb27", "metadata": {}, "source": [ "## GET RMSE MEAN by ICP Methods\n", "\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "e49285b9", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3]\n", " file_1 file_2 file_3 file_4 file_5 file_6 file_7 file_8 file_9 file_10 file_11 file_12 file_13 file_14 file_15 file_16 file_17 file_18 file_19 file_20 file_21 file_22 file_23 file_24 file_25 mean_Val\n", "ICP 87.744412 98.518325 107.27417 108.915958 107.804237 95.335683 88.377373 105.16027 69.119888 79.866348 82.84529 39.959197 40.642882 31.268533 41.314721 29.972667 41.554109 30.184092 42.781293 42.394746 23.930078 24.056654 15.870289 0.0 0.0 69.797605\n", "FAST ICP 87.788162 98.534844 108.922811 90.815939 107.836106 95.33875 88.390579 105.200073 70.713267 80.173948 84.938867 39.966042 39.833893 31.249946 28.363155 29.974939 41.57834 30.171052 42.786047 42.366685 23.928099 6.842376 15.881596 0.0 0.0 67.787367\n", "FAST AND ROBUST ICP 93.305678 102.2198 108.10919 83.852394 102.618093 94.620482 80.982007 85.243247 67.540474 77.336807 86.660331 32.594186 30.947539 21.018905 23.236369 20.958612 32.428754 23.611909 32.614269 32.400129 26.233094 27.865345 16.27848 0.0 0.0 63.144973\n", "SPARSE ICP 84.586116 100.282858 104.159789 106.510953 99.573198 93.270666 91.859551 94.742084 71.836342 83.758905 87.252521 41.695268 39.255679 29.86665 27.689535 28.251518 39.503817 26.513459 38.778507 39.29655 23.858668 24.422417 10.685429 0.0 0.0 67.541520\n", "\n" ] } ], "source": [ "df_mean = np.zeros((5,5))\n", "\n", "## make 25 lengths array\n", "\n", "grouping = []\n", "\n", "for i in range(0,len(df)):\n", " grouping.append(i)\n", "\n", "grouping = np.arange(len(df)) //5\n", "\n", "print(grouping)\n", "block_avg_df = df.groupby(grouping).mean()\n", "\n", "\n", "ICP_Method = ['ICP', 'FAST ICP', 'FAST AND ROBUST ICP', 'SPARSE ICP']\n", "\n", "\n", "\n", "block_avg_df.index = ICP_Method\n", "\n", "\n", "print(block_avg_df)\n", "\n", "print(type(block_avg_df))\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "14ebb074", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "d03a908e", "metadata": {}, "source": [ "## merge in Pandas" ] }, { "cell_type": "code", "execution_count": 6, "id": "92386801", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " file_1 file_2 file_3 file_4 file_5 file_6 file_7 file_8 file_9 file_10 file_11 file_12 file_13 file_14 file_15 file_16 file_17 file_18 file_19 file_20 file_21 file_22 file_23 file_24 file_25 mean_Val\n", "lightbulb_100_ICP 103.98447 104.565353 109.818912 107.240433 106.78074 107.061836 103.506492 96.975858 38.905718 34.743611 45.630022 12.332753 11.745771 13.350829 13.042864 14.351614 13.834044 14.051612 13.570112 13.979531 0.0 0.0 0.0 0.0 0.0 53.973629\n", "lightbulb_75_ICP 0.0 52.302238 83.250963 102.904808 106.562496 112.206058 111.43725 104.932135 89.953663 71.745028 33.891212 8.607876 13.091517 11.538156 12.406693 12.896077 8.602728 7.361024 10.180717 9.915981 0.0 0.0 0.0 0.0 0.0 50.725612\n", "lightbulb_50_ICP 113.13122 113.692223 112.735607 104.421379 101.188747 54.861169 61.130873 101.7967 108.469629 110.270757 106.106512 9.824989 12.517988 14.214799 13.292146 11.522909 13.605216 14.656726 14.853134 14.169484 0.0 0.0 0.0 0.0 0.0 60.323110\n", "lightbulb_25_ICP 112.191236 112.346354 113.124372 110.304337 104.219034 82.676305 44.830521 103.151362 108.27043 111.99015 111.272516 11.507546 13.049302 14.189969 10.77711 8.797878 13.377637 11.447832 13.629581 13.947722 0.0 0.0 0.0 0.0 0.0 61.255060\n", "lightbulb_0_ICP 109.415136 109.685456 117.440993 119.708833 120.270167 119.873045 120.981727 118.945298 0.0 70.582195 117.326187 157.522821 152.809831 103.048911 157.05479 102.294857 158.350918 103.403266 161.672922 159.961013 119.650388 120.283269 79.351446 0.0 0.0 122.710612\n", "lightbulb_100_FAST ICP 104.035583 104.635462 109.824508 107.196339 106.807446 107.145793 103.558118 97.06873 41.346621 36.813222 45.653219 12.330299 11.742075 13.340981 13.035206 14.353184 13.860245 14.045991 13.570413 13.979327 0.0 0.0 0.0 0.0 0.0 54.217138\n", "lightbulb_75_FAST ICP 0.0 52.207646 92.523859 102.880223 106.669757 112.181805 111.412737 104.932667 95.458434 71.756326 44.621859 8.625912 13.085044 11.53846 12.414036 12.903166 8.641926 7.365058 10.194541 9.899811 0.0 0.0 0.0 0.0 0.0 52.069119\n", "lightbulb_50_FAST ICP 113.230928 113.684427 111.707186 104.432407 101.206555 54.764861 61.130778 101.799637 108.469629 110.159112 105.704763 9.861285 12.531409 14.237861 13.309401 11.524188 13.616516 14.608723 14.897899 14.200284 0.0 0.0 0.0 0.0 0.0 60.253892\n", "lightbulb_25_FAST ICP 112.217262 112.400942 113.150651 19.865874 104.264638 82.730436 44.877268 103.144409 108.291652 111.990024 111.325549 11.488449 12.881126 14.195493 10.778225 8.807527 13.400508 11.484493 13.599075 13.940525 0.0 0.0 0.0 0.0 0.0 56.741706\n", "lightbulb_0_FAST ICP 109.457035 109.745744 117.407852 119.704853 120.232133 119.870854 120.973994 119.054922 0.0 70.151056 117.388946 157.524266 148.929811 102.936934 92.278907 102.286628 158.372504 103.350994 161.668309 159.813477 119.640495 34.211878 79.407981 0.0 0.0 115.654981\n", "lightbulb_100_Robust ICP 100.656553 100.265772 112.031006 112.095672 108.695883 93.246246 90.690985 83.059558 30.852626 22.604074 34.335439 2.804439 2.136346 2.844818 2.274384 2.040661 2.516029 2.72491 2.080608 2.012554 0.0 0.0 0.0 0.0 0.0 45.498428\n", "lightbulb_75_Robust ICP 0.0 44.409336 74.2255 90.365606 111.334952 111.333646 112.268981 100.980737 81.97706 61.777594 37.228097 1.924535 2.117269 2.080452 1.916491 2.190268 2.404712 3.478067 1.854583 1.611274 0.0 0.0 0.0 0.0 0.0 44.498903\n", "lightbulb_50_Robust ICP 112.188085 112.813444 112.251775 100.313877 87.889018 76.085361 1.173045 82.535445 111.379307 111.986331 111.558323 2.46845 2.42472 3.260555 1.431749 1.752413 1.737649 1.699779 1.770173 1.85551 0.0 0.0 0.0 0.0 0.0 51.928750\n", "lightbulb_25_Robust ICP 112.183205 111.819097 112.070231 4.601354 93.02836 80.797439 68.275646 97.402529 113.493377 112.485894 111.83982 3.944205 1.941063 1.72179 2.1447 2.700865 3.007329 2.526044 2.52136 3.651088 0.0 0.0 0.0 0.0 0.0 52.107770\n", "lightbulb_0_Robust ICP 141.500546 141.791352 129.967436 111.885463 112.142252 111.639716 132.501379 62.237965 0.0 77.830141 138.339977 151.829302 146.118296 95.186908 108.414518 96.108852 152.478053 107.630745 154.844619 152.870221 131.165472 139.326725 81.392398 0.0 0.0 121.691015\n", "lightbulb_100_Sparse ICP 90.700462 91.900485 108.008969 107.551359 99.033223 94.249693 78.442598 78.73422 57.989718 54.073644 63.75587 17.205612 16.85667 14.552057 16.356058 10.23808 11.839222 8.803319 12.77988 12.340294 0.0 0.0 0.0 0.0 0.0 52.270571\n", "lightbulb_75_Sparse ICP 0.0 70.939789 81.208288 87.52666 98.027725 108.576385 109.05019 98.077001 84.005557 81.306692 49.211489 15.64117 13.350377 15.402829 15.8654 15.971973 20.067033 20.197904 14.983979 19.787337 0.0 0.0 0.0 0.0 0.0 53.641988\n", "lightbulb_50_Sparse ICP 108.898934 109.432985 108.397308 103.50428 81.367205 60.489969 81.810123 79.575695 108.109763 108.619567 99.862084 13.879029 10.557673 8.525973 9.765928 12.758249 6.080241 1.523862 1.94761 1.730347 0.0 0.0 0.0 0.0 0.0 55.841841\n", "lightbulb_25_Sparse ICP 108.787752 109.174225 109.550695 109.617117 97.302117 85.187885 68.785826 94.114236 109.076674 109.682342 108.142645 5.123658 3.490953 6.681561 1.950736 2.777171 2.561626 2.567981 2.853046 4.211883 0.0 0.0 0.0 0.0 0.0 57.082006\n", "lightbulb_0_Sparse ICP 114.543432 119.966806 113.633685 124.355348 122.135718 117.8494 121.209017 123.209265 0.0 65.11228 115.290516 156.626871 152.022722 104.170831 94.509555 99.512119 156.970963 99.474232 161.32802 158.412887 119.293342 122.112083 53.427143 0.0 0.0 118.871192\n", "ICP 87.744412 98.518325 107.27417 108.915958 107.804237 95.335683 88.377373 105.16027 69.119888 79.866348 82.84529 39.959197 40.642882 31.268533 41.314721 29.972667 41.554109 30.184092 42.781293 42.394746 23.930078 24.056654 15.870289 0.0 0.0 69.797605\n", "FAST ICP 87.788162 98.534844 108.922811 90.815939 107.836106 95.33875 88.390579 105.200073 70.713267 80.173948 84.938867 39.966042 39.833893 31.249946 28.363155 29.974939 41.57834 30.171052 42.786047 42.366685 23.928099 6.842376 15.881596 0.0 0.0 67.787367\n", "FAST AND ROBUST ICP 93.305678 102.2198 108.10919 83.852394 102.618093 94.620482 80.982007 85.243247 67.540474 77.336807 86.660331 32.594186 30.947539 21.018905 23.236369 20.958612 32.428754 23.611909 32.614269 32.400129 26.233094 27.865345 16.27848 0.0 0.0 63.144973\n", "SPARSE ICP 84.586116 100.282858 104.159789 106.510953 99.573198 93.270666 91.859551 94.742084 71.836342 83.758905 87.252521 41.695268 39.255679 29.86665 27.689535 28.251518 39.503817 26.513459 38.778507 39.29655 23.858668 24.422417 10.685429 0.0 0.0 67.541520\n" ] } ], "source": [ "combined_df = pd.concat([df, block_avg_df], ignore_index=False)\n", "\n", "# 모든 행/열을 전부 보여줌\n", "pd.set_option('display.max_rows', None) # 행 전체 출력\n", "pd.set_option('display.max_columns', None) # 열 전체 출력\n", "\n", "# 각 열의 너비 제한 해제 (긴 문자열도 잘리지 않음)\n", "pd.set_option('display.max_colwidth', None)\n", "\n", "# 화면 너비에 따라 줄바꿈을 할지 말지\n", "pd.set_option('display.width', None) # None이면 자동으로 콘솔 너비를 사용\n", "pd.set_option('display.expand_frame_repr', False) # True면 줄바꿈 허용, False면 한 줄로 출력 시도\n", "\n", "print(combined_df)" ] }, { "cell_type": "markdown", "id": "a9b19689", "metadata": {}, "source": [ "## Save bottle csv" ] }, { "cell_type": "code", "execution_count": 7, "id": "9e8dcfae", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ICP 69.797605\n", "FAST ICP 67.787367\n", "FAST AND ROBUST ICP 63.144973\n", "SPARSE ICP 67.541520\n", "Name: mean_Val, dtype: float64\n" ] } ], "source": [ "sliced_data = combined_df.loc['ICP':'SPARSE ICP', 'mean_Val']\n", "print(sliced_data)\n", "combined_df.to_csv(f'{category}.csv', index=True)" ] }, { "cell_type": "markdown", "id": "2b3a2e20", "metadata": {}, "source": [ "## Load num of dataset in each category. + save array" ] }, { "cell_type": "code", "execution_count": 8, "id": "b9422b65", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " file_1 file_2 file_3 file_4 file_5 file_6 file_7 file_8 file_9 file_10 file_11 file_12 file_13 file_14 file_15 file_16 file_17 file_18 file_19 file_20 file_21 file_22 file_23 file_24 file_25 mean_Val Counts\n", "lightbulb_100_ICP 103.98447 104.565353 109.818912 107.240433 106.78074 107.061836 103.506492 96.975858 38.905718 34.743611 45.630022 12.332753 11.745771 13.350829 13.042864 14.351614 13.834044 14.051612 13.570112 13.979531 0.0 0.0 0.0 0.0 0.0 53.973629 20\n", "lightbulb_75_ICP 0.0 52.302238 83.250963 102.904808 106.562496 112.206058 111.43725 104.932135 89.953663 71.745028 33.891212 8.607876 13.091517 11.538156 12.406693 12.896077 8.602728 7.361024 10.180717 9.915981 0.0 0.0 0.0 0.0 0.0 50.725612 19\n", "lightbulb_50_ICP 113.13122 113.692223 112.735607 104.421379 101.188747 54.861169 61.130873 101.7967 108.469629 110.270757 106.106512 9.824989 12.517988 14.214799 13.292146 11.522909 13.605216 14.656726 14.853134 14.169484 0.0 0.0 0.0 0.0 0.0 60.323110 20\n", "lightbulb_25_ICP 112.191236 112.346354 113.124372 110.304337 104.219034 82.676305 44.830521 103.151362 108.27043 111.99015 111.272516 11.507546 13.049302 14.189969 10.77711 8.797878 13.377637 11.447832 13.629581 13.947722 0.0 0.0 0.0 0.0 0.0 61.255060 20\n", "lightbulb_0_ICP 109.415136 109.685456 117.440993 119.708833 120.270167 119.873045 120.981727 118.945298 0.0 70.582195 117.326187 157.522821 152.809831 103.048911 157.05479 102.294857 158.350918 103.403266 161.672922 159.961013 119.650388 120.283269 79.351446 0.0 0.0 122.710612 22\n", "lightbulb_100_FAST ICP 104.035583 104.635462 109.824508 107.196339 106.807446 107.145793 103.558118 97.06873 41.346621 36.813222 45.653219 12.330299 11.742075 13.340981 13.035206 14.353184 13.860245 14.045991 13.570413 13.979327 0.0 0.0 0.0 0.0 0.0 54.217138 20\n", "lightbulb_75_FAST ICP 0.0 52.207646 92.523859 102.880223 106.669757 112.181805 111.412737 104.932667 95.458434 71.756326 44.621859 8.625912 13.085044 11.53846 12.414036 12.903166 8.641926 7.365058 10.194541 9.899811 0.0 0.0 0.0 0.0 0.0 52.069119 19\n", "lightbulb_50_FAST ICP 113.230928 113.684427 111.707186 104.432407 101.206555 54.764861 61.130778 101.799637 108.469629 110.159112 105.704763 9.861285 12.531409 14.237861 13.309401 11.524188 13.616516 14.608723 14.897899 14.200284 0.0 0.0 0.0 0.0 0.0 60.253892 20\n", "lightbulb_25_FAST ICP 112.217262 112.400942 113.150651 19.865874 104.264638 82.730436 44.877268 103.144409 108.291652 111.990024 111.325549 11.488449 12.881126 14.195493 10.778225 8.807527 13.400508 11.484493 13.599075 13.940525 0.0 0.0 0.0 0.0 0.0 56.741706 20\n", "lightbulb_0_FAST ICP 109.457035 109.745744 117.407852 119.704853 120.232133 119.870854 120.973994 119.054922 0.0 70.151056 117.388946 157.524266 148.929811 102.936934 92.278907 102.286628 158.372504 103.350994 161.668309 159.813477 119.640495 34.211878 79.407981 0.0 0.0 115.654981 22\n", "lightbulb_100_Robust ICP 100.656553 100.265772 112.031006 112.095672 108.695883 93.246246 90.690985 83.059558 30.852626 22.604074 34.335439 2.804439 2.136346 2.844818 2.274384 2.040661 2.516029 2.72491 2.080608 2.012554 0.0 0.0 0.0 0.0 0.0 45.498428 20\n", "lightbulb_75_Robust ICP 0.0 44.409336 74.2255 90.365606 111.334952 111.333646 112.268981 100.980737 81.97706 61.777594 37.228097 1.924535 2.117269 2.080452 1.916491 2.190268 2.404712 3.478067 1.854583 1.611274 0.0 0.0 0.0 0.0 0.0 44.498903 19\n", "lightbulb_50_Robust ICP 112.188085 112.813444 112.251775 100.313877 87.889018 76.085361 1.173045 82.535445 111.379307 111.986331 111.558323 2.46845 2.42472 3.260555 1.431749 1.752413 1.737649 1.699779 1.770173 1.85551 0.0 0.0 0.0 0.0 0.0 51.928750 20\n", "lightbulb_25_Robust ICP 112.183205 111.819097 112.070231 4.601354 93.02836 80.797439 68.275646 97.402529 113.493377 112.485894 111.83982 3.944205 1.941063 1.72179 2.1447 2.700865 3.007329 2.526044 2.52136 3.651088 0.0 0.0 0.0 0.0 0.0 52.107770 20\n", "lightbulb_0_Robust ICP 141.500546 141.791352 129.967436 111.885463 112.142252 111.639716 132.501379 62.237965 0.0 77.830141 138.339977 151.829302 146.118296 95.186908 108.414518 96.108852 152.478053 107.630745 154.844619 152.870221 131.165472 139.326725 81.392398 0.0 0.0 121.691015 22\n", "lightbulb_100_Sparse ICP 90.700462 91.900485 108.008969 107.551359 99.033223 94.249693 78.442598 78.73422 57.989718 54.073644 63.75587 17.205612 16.85667 14.552057 16.356058 10.23808 11.839222 8.803319 12.77988 12.340294 0.0 0.0 0.0 0.0 0.0 52.270571 20\n", "lightbulb_75_Sparse ICP 0.0 70.939789 81.208288 87.52666 98.027725 108.576385 109.05019 98.077001 84.005557 81.306692 49.211489 15.64117 13.350377 15.402829 15.8654 15.971973 20.067033 20.197904 14.983979 19.787337 0.0 0.0 0.0 0.0 0.0 53.641988 19\n", "lightbulb_50_Sparse ICP 108.898934 109.432985 108.397308 103.50428 81.367205 60.489969 81.810123 79.575695 108.109763 108.619567 99.862084 13.879029 10.557673 8.525973 9.765928 12.758249 6.080241 1.523862 1.94761 1.730347 0.0 0.0 0.0 0.0 0.0 55.841841 20\n", "lightbulb_25_Sparse ICP 108.787752 109.174225 109.550695 109.617117 97.302117 85.187885 68.785826 94.114236 109.076674 109.682342 108.142645 5.123658 3.490953 6.681561 1.950736 2.777171 2.561626 2.567981 2.853046 4.211883 0.0 0.0 0.0 0.0 0.0 57.082006 20\n", "lightbulb_0_Sparse ICP 114.543432 119.966806 113.633685 124.355348 122.135718 117.8494 121.209017 123.209265 0.0 65.11228 115.290516 156.626871 152.022722 104.170831 94.509555 99.512119 156.970963 99.474232 161.32802 158.412887 119.293342 122.112083 53.427143 0.0 0.0 118.871192 22\n", "###################\n", "lightbulb_100_ICP 20\n", "lightbulb_75_ICP 19\n", "lightbulb_50_ICP 20\n", "lightbulb_25_ICP 20\n", "lightbulb_0_ICP 22\n", "Name: Counts, dtype: int64\n" ] } ], "source": [ "\n", "\n", "df['Counts'] = (df != 0).sum(axis=1)-1\n", "\n", "# 모든 행/열을 전부 보여줌\n", "pd.set_option('display.max_rows', None) # 행 전체 출력\n", "pd.set_option('display.max_columns', None) # 열 전체 출력\n", "\n", "# 각 열의 너비 제한 해제 (긴 문자열도 잘리지 않음)\n", "pd.set_option('display.max_colwidth', None)\n", "\n", "# 화면 너비에 따라 줄바꿈을 할지 말지\n", "pd.set_option('display.width', None) # None이면 자동으로 콘솔 너비를 사용\n", "pd.set_option('display.expand_frame_repr', False) # True면 줄바꿈 허용, False면 한 줄로 출력 시도\n", "\n", "print(df)\n", "\n", "\n", "\n", "sliced_data = df.loc['lightbulb_100_ICP':'lightbulb_0_ICP', 'Counts']\n", "print(f\"###################\\n{sliced_data}\")\n", "sliced_data.to_csv(f'{category}_data_num.csv', index=True)" ] } ], "metadata": { "kernelspec": { "display_name": "icp", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.19" } }, "nbformat": 4, "nbformat_minor": 5 }