{ "cells": [ { "cell_type": "markdown", "id": "781eee9c", "metadata": {}, "source": [ "## using pandas\n" ] }, { "cell_type": "code", "execution_count": 9, "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[0]\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": 10, "id": "86c0ea73", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 10, "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": 11, "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": 12, "id": "c4883f09", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "⚠️ 경고: './gt_raw/noisy_filtered_0_12.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_0_17.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_0_12.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_0_17.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_0_12.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_0_17.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_0_12.json' 경로에 파일이 없습니다. 해당 처리를 건너뜁니다.\n", "⚠️ 경고: './gt_raw/noisy_filtered_0_17.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", "bottle2_100_ICP 57.726431 58.073827 57.979086 69.954194 53.573036 52.09264 70.639847 66.144313 72.694435 72.247312 67.095363 39.427028 36.097347 51.937576 60.991109 70.36314 70.532546 72.729103 55.116216 54.524579 0.0 0.0 0.0 0.0 0.0 60.496956\n", "bottle2_75_ICP 66.557193 67.623246 58.069773 68.352285 45.998694 63.978648 59.741997 71.648534 70.064837 53.158668 60.973961 38.136257 36.259578 55.429318 69.340292 69.000672 71.16037 60.483901 55.862601 66.854347 0.0 0.0 0.0 0.0 0.0 60.434759\n", "bottle2_50_ICP 54.377858 53.393512 66.12583 47.561213 51.31821 57.560825 68.805384 55.289464 73.306761 70.184317 65.496406 71.789794 67.639152 54.298582 60.46459 38.607896 35.885329 37.012867 57.479033 71.525565 0.0 0.0 0.0 0.0 0.0 57.906129\n", "bottle2_25_ICP 71.730017 70.795363 63.555661 67.25048 63.613194 51.285702 42.303407 39.39284 65.657843 67.373311 79.379446 51.375709 55.391288 51.114255 56.139717 53.657441 70.10359 71.862892 82.068982 67.205189 0.0 0.0 0.0 0.0 0.0 62.062816\n", "bottle2_0_ICP 80.541255 78.927351 86.367711 51.188665 47.259758 23.529144 26.495752 26.307019 58.988365 87.186705 94.964133 0.0 60.931521 56.640394 30.727522 30.044528 0.0 89.849671 79.279781 24.165655 94.358841 33.815192 45.865195 0.0 0.0 57.496865\n", "bottle2_100_FAST ICP 57.688938 58.073827 57.95261 69.895066 53.288431 52.095725 70.636632 66.160966 72.69402 72.207366 66.179926 39.479096 36.090186 51.322082 60.814999 70.445922 70.538539 72.740172 55.116972 54.539657 0.0 0.0 0.0 0.0 0.0 60.398057\n", "bottle2_75_FAST ICP 44.860989 67.613803 58.069773 68.358055 46.042018 64.441146 59.721992 71.641551 70.052412 53.481736 60.979005 38.131182 55.091599 55.153897 69.289835 68.607169 71.218541 59.599214 55.860476 67.014762 0.0 0.0 0.0 0.0 0.0 60.261458\n", "bottle2_50_FAST ICP 48.445113 53.266916 66.128142 47.394348 51.068578 57.519886 68.855187 66.043425 73.383533 70.153381 65.461271 71.790779 68.849646 54.293063 60.622404 38.606699 35.904505 36.900701 57.872143 72.136896 0.0 0.0 0.0 0.0 0.0 58.234831\n", "bottle2_25_FAST ICP 71.730556 70.813613 48.390064 67.208482 63.630603 51.294102 42.303407 39.394111 65.684234 67.362821 79.37104 51.333991 51.569497 51.046581 56.147149 53.361444 67.824738 71.863382 82.072543 67.188839 0.0 0.0 0.0 0.0 0.0 60.979560\n", "bottle2_0_FAST ICP 80.541086 78.927351 86.369584 49.968808 47.255769 23.557333 26.504626 26.359362 58.95614 87.183452 94.944673 0.0 60.904371 56.000499 30.738225 27.684303 0.0 89.849728 79.276977 22.581162 94.359098 33.984328 43.870373 0.0 0.0 57.134155\n", "bottle2_100_Robust ICP 50.504351 49.133166 49.608769 65.247935 42.131387 43.924281 68.181318 59.094124 67.919525 67.379707 50.458574 52.717507 34.114118 54.92686 57.805806 65.611106 61.177957 65.368603 41.45572 50.579692 0.0 0.0 0.0 0.0 0.0 54.867025\n", "bottle2_75_Robust ICP 65.171352 54.045867 36.901146 54.330906 47.420552 65.597031 55.602239 66.911923 67.495546 36.590494 52.79024 32.480709 50.646411 48.142464 56.953986 62.867727 57.595423 52.695511 51.982744 50.382476 0.0 0.0 0.0 0.0 0.0 53.330237\n", "bottle2_50_Robust ICP 47.771693 45.012185 57.661057 42.412898 44.792427 56.455638 59.622745 50.11804 57.469541 62.813152 55.040781 61.801269 59.122552 53.439211 61.519585 28.646356 55.147605 37.786525 62.005449 61.623284 0.0 0.0 0.0 0.0 0.0 53.013100\n", "bottle2_25_Robust ICP 68.372297 65.913029 60.802011 62.199418 62.664916 48.949447 49.991884 6.183673 49.365622 57.576716 59.482653 47.27592 61.409181 39.522688 46.994318 45.567914 57.165478 60.199405 58.092839 65.6003 0.0 0.0 0.0 0.0 0.0 53.666485\n", "bottle2_0_Robust ICP 64.716537 62.513045 62.81728 49.088234 45.262582 33.32966 21.138026 11.118374 47.963994 76.110225 73.256406 0.0 60.237215 77.414676 49.737045 9.669534 0.0 73.509738 69.848925 36.882767 73.228013 19.113386 47.360497 0.0 0.0 50.681722\n", "bottle2_100_Sparse ICP 53.412883 53.800208 52.790838 57.532525 53.838994 48.981065 62.133405 60.96027 76.258964 67.811151 60.9657 39.873357 41.373595 55.00382 59.390746 62.465343 67.976456 65.191948 52.286949 45.004554 0.0 0.0 0.0 0.0 0.0 56.852639\n", "bottle2_75_Sparse ICP 60.758925 62.083034 53.335445 51.852443 48.473864 57.978259 61.524882 65.698803 66.304336 58.831034 56.198062 36.067757 44.468705 56.804776 63.106554 65.245407 69.781086 65.129953 65.362751 51.36387 0.0 0.0 0.0 0.0 0.0 58.018497\n", "bottle2_50_Sparse ICP 63.234282 62.944344 65.182522 48.120253 52.935785 52.932735 55.108551 62.309733 76.492421 62.961988 66.740594 66.057711 64.091673 57.605262 52.913206 48.140719 39.945907 32.604047 50.441113 66.71904 0.0 0.0 0.0 0.0 0.0 57.374094\n", "bottle2_25_Sparse ICP 68.338245 67.504931 60.979872 57.887682 58.421357 30.656694 31.248467 43.173549 62.545731 68.838698 78.791105 53.815284 47.591621 49.769237 52.289646 57.737586 62.937188 66.062745 79.519469 57.498068 0.0 0.0 0.0 0.0 0.0 57.780359\n", "bottle2_0_Sparse ICP 74.964649 64.046069 72.359844 54.094445 53.676616 27.231209 23.413694 20.608975 55.196291 91.152314 82.327922 0.0 72.626788 63.141163 28.504973 23.181661 0.0 74.259527 74.642275 65.102882 82.026225 27.648789 64.4469 0.0 0.0 56.888248\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/tmp/ipykernel_270442/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": 13, "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 66.186551 65.76266 66.419612 60.861367 52.352578 49.689392 53.597278 51.756434 68.142448 70.030063 73.581862 40.145757 51.263777 53.884025 55.532646 52.334736 49.536367 66.387687 65.961323 56.855067 18.871768 6.763038 9.173039 0.0 0.0 59.679505\n", "FAST ICP 60.653336 65.739102 63.382035 60.564952 52.25708 49.781638 53.604369 53.919883 68.154068 70.077751 73.387183 40.14701 54.50106 53.563224 55.522523 51.741107 49.097265 66.190639 66.039822 56.692263 18.87182 6.796866 8.774075 0.0 0.0 59.401612\n", "FAST AND ROBUST ICP 59.307246 55.323458 53.558052 54.655878 48.454373 49.651212 50.907243 38.685227 58.042846 60.094059 58.205731 38.855081 53.105895 54.68918 54.602148 42.472527 46.217293 57.911956 56.677135 53.013704 14.645603 3.822677 9.472099 0.0 0.0 53.111714\n", "SPARSE ICP 64.141797 62.075717 60.929704 53.89747 53.469323 43.555993 46.6858 50.550266 67.359549 69.919037 69.004677 39.162822 54.030476 56.464851 51.241025 51.354143 48.128127 60.649644 64.450511 57.137683 16.405245 5.529758 12.88938 0.0 0.0 57.382767\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": 14, "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", "bottle2_100_ICP 57.726431 58.073827 57.979086 69.954194 53.573036 52.09264 70.639847 66.144313 72.694435 72.247312 67.095363 39.427028 36.097347 51.937576 60.991109 70.36314 70.532546 72.729103 55.116216 54.524579 0.0 0.0 0.0 0.0 0.0 60.496956\n", "bottle2_75_ICP 66.557193 67.623246 58.069773 68.352285 45.998694 63.978648 59.741997 71.648534 70.064837 53.158668 60.973961 38.136257 36.259578 55.429318 69.340292 69.000672 71.16037 60.483901 55.862601 66.854347 0.0 0.0 0.0 0.0 0.0 60.434759\n", "bottle2_50_ICP 54.377858 53.393512 66.12583 47.561213 51.31821 57.560825 68.805384 55.289464 73.306761 70.184317 65.496406 71.789794 67.639152 54.298582 60.46459 38.607896 35.885329 37.012867 57.479033 71.525565 0.0 0.0 0.0 0.0 0.0 57.906129\n", "bottle2_25_ICP 71.730017 70.795363 63.555661 67.25048 63.613194 51.285702 42.303407 39.39284 65.657843 67.373311 79.379446 51.375709 55.391288 51.114255 56.139717 53.657441 70.10359 71.862892 82.068982 67.205189 0.0 0.0 0.0 0.0 0.0 62.062816\n", "bottle2_0_ICP 80.541255 78.927351 86.367711 51.188665 47.259758 23.529144 26.495752 26.307019 58.988365 87.186705 94.964133 0.0 60.931521 56.640394 30.727522 30.044528 0.0 89.849671 79.279781 24.165655 94.358841 33.815192 45.865195 0.0 0.0 57.496865\n", "bottle2_100_FAST ICP 57.688938 58.073827 57.95261 69.895066 53.288431 52.095725 70.636632 66.160966 72.69402 72.207366 66.179926 39.479096 36.090186 51.322082 60.814999 70.445922 70.538539 72.740172 55.116972 54.539657 0.0 0.0 0.0 0.0 0.0 60.398057\n", "bottle2_75_FAST ICP 44.860989 67.613803 58.069773 68.358055 46.042018 64.441146 59.721992 71.641551 70.052412 53.481736 60.979005 38.131182 55.091599 55.153897 69.289835 68.607169 71.218541 59.599214 55.860476 67.014762 0.0 0.0 0.0 0.0 0.0 60.261458\n", "bottle2_50_FAST ICP 48.445113 53.266916 66.128142 47.394348 51.068578 57.519886 68.855187 66.043425 73.383533 70.153381 65.461271 71.790779 68.849646 54.293063 60.622404 38.606699 35.904505 36.900701 57.872143 72.136896 0.0 0.0 0.0 0.0 0.0 58.234831\n", "bottle2_25_FAST ICP 71.730556 70.813613 48.390064 67.208482 63.630603 51.294102 42.303407 39.394111 65.684234 67.362821 79.37104 51.333991 51.569497 51.046581 56.147149 53.361444 67.824738 71.863382 82.072543 67.188839 0.0 0.0 0.0 0.0 0.0 60.979560\n", "bottle2_0_FAST ICP 80.541086 78.927351 86.369584 49.968808 47.255769 23.557333 26.504626 26.359362 58.95614 87.183452 94.944673 0.0 60.904371 56.000499 30.738225 27.684303 0.0 89.849728 79.276977 22.581162 94.359098 33.984328 43.870373 0.0 0.0 57.134155\n", "bottle2_100_Robust ICP 50.504351 49.133166 49.608769 65.247935 42.131387 43.924281 68.181318 59.094124 67.919525 67.379707 50.458574 52.717507 34.114118 54.92686 57.805806 65.611106 61.177957 65.368603 41.45572 50.579692 0.0 0.0 0.0 0.0 0.0 54.867025\n", "bottle2_75_Robust ICP 65.171352 54.045867 36.901146 54.330906 47.420552 65.597031 55.602239 66.911923 67.495546 36.590494 52.79024 32.480709 50.646411 48.142464 56.953986 62.867727 57.595423 52.695511 51.982744 50.382476 0.0 0.0 0.0 0.0 0.0 53.330237\n", "bottle2_50_Robust ICP 47.771693 45.012185 57.661057 42.412898 44.792427 56.455638 59.622745 50.11804 57.469541 62.813152 55.040781 61.801269 59.122552 53.439211 61.519585 28.646356 55.147605 37.786525 62.005449 61.623284 0.0 0.0 0.0 0.0 0.0 53.013100\n", "bottle2_25_Robust ICP 68.372297 65.913029 60.802011 62.199418 62.664916 48.949447 49.991884 6.183673 49.365622 57.576716 59.482653 47.27592 61.409181 39.522688 46.994318 45.567914 57.165478 60.199405 58.092839 65.6003 0.0 0.0 0.0 0.0 0.0 53.666485\n", "bottle2_0_Robust ICP 64.716537 62.513045 62.81728 49.088234 45.262582 33.32966 21.138026 11.118374 47.963994 76.110225 73.256406 0.0 60.237215 77.414676 49.737045 9.669534 0.0 73.509738 69.848925 36.882767 73.228013 19.113386 47.360497 0.0 0.0 50.681722\n", "bottle2_100_Sparse ICP 53.412883 53.800208 52.790838 57.532525 53.838994 48.981065 62.133405 60.96027 76.258964 67.811151 60.9657 39.873357 41.373595 55.00382 59.390746 62.465343 67.976456 65.191948 52.286949 45.004554 0.0 0.0 0.0 0.0 0.0 56.852639\n", "bottle2_75_Sparse ICP 60.758925 62.083034 53.335445 51.852443 48.473864 57.978259 61.524882 65.698803 66.304336 58.831034 56.198062 36.067757 44.468705 56.804776 63.106554 65.245407 69.781086 65.129953 65.362751 51.36387 0.0 0.0 0.0 0.0 0.0 58.018497\n", "bottle2_50_Sparse ICP 63.234282 62.944344 65.182522 48.120253 52.935785 52.932735 55.108551 62.309733 76.492421 62.961988 66.740594 66.057711 64.091673 57.605262 52.913206 48.140719 39.945907 32.604047 50.441113 66.71904 0.0 0.0 0.0 0.0 0.0 57.374094\n", "bottle2_25_Sparse ICP 68.338245 67.504931 60.979872 57.887682 58.421357 30.656694 31.248467 43.173549 62.545731 68.838698 78.791105 53.815284 47.591621 49.769237 52.289646 57.737586 62.937188 66.062745 79.519469 57.498068 0.0 0.0 0.0 0.0 0.0 57.780359\n", "bottle2_0_Sparse ICP 74.964649 64.046069 72.359844 54.094445 53.676616 27.231209 23.413694 20.608975 55.196291 91.152314 82.327922 0.0 72.626788 63.141163 28.504973 23.181661 0.0 74.259527 74.642275 65.102882 82.026225 27.648789 64.4469 0.0 0.0 56.888248\n", "ICP 66.186551 65.76266 66.419612 60.861367 52.352578 49.689392 53.597278 51.756434 68.142448 70.030063 73.581862 40.145757 51.263777 53.884025 55.532646 52.334736 49.536367 66.387687 65.961323 56.855067 18.871768 6.763038 9.173039 0.0 0.0 59.679505\n", "FAST ICP 60.653336 65.739102 63.382035 60.564952 52.25708 49.781638 53.604369 53.919883 68.154068 70.077751 73.387183 40.14701 54.50106 53.563224 55.522523 51.741107 49.097265 66.190639 66.039822 56.692263 18.87182 6.796866 8.774075 0.0 0.0 59.401612\n", "FAST AND ROBUST ICP 59.307246 55.323458 53.558052 54.655878 48.454373 49.651212 50.907243 38.685227 58.042846 60.094059 58.205731 38.855081 53.105895 54.68918 54.602148 42.472527 46.217293 57.911956 56.677135 53.013704 14.645603 3.822677 9.472099 0.0 0.0 53.111714\n", "SPARSE ICP 64.141797 62.075717 60.929704 53.89747 53.469323 43.555993 46.6858 50.550266 67.359549 69.919037 69.004677 39.162822 54.030476 56.464851 51.241025 51.354143 48.128127 60.649644 64.450511 57.137683 16.405245 5.529758 12.88938 0.0 0.0 57.382767\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": 15, "id": "9e8dcfae", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ICP 59.679505\n", "FAST ICP 59.401612\n", "FAST AND ROBUST ICP 53.111714\n", "SPARSE ICP 57.382767\n", "Name: mean_Val, dtype: float64\n" ] } ], "source": [ "sliced_data = combined_df.loc['ICP':'SPARSE ICP', 'mean_Val']\n", "print(sliced_data)\n", "sliced_data.to_csv(f'{category}.csv', index=True)" ] }, { "cell_type": "markdown", "id": "fdbb5b00", "metadata": {}, "source": [ "## Load num of dataset in each category. + save array" ] }, { "cell_type": "code", "execution_count": 16, "id": "7461379a", "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", "bottle2_100_ICP 57.726431 58.073827 57.979086 69.954194 53.573036 52.09264 70.639847 66.144313 72.694435 72.247312 67.095363 39.427028 36.097347 51.937576 60.991109 70.36314 70.532546 72.729103 55.116216 54.524579 0.0 0.0 0.0 0.0 0.0 60.496956 20\n", "bottle2_75_ICP 66.557193 67.623246 58.069773 68.352285 45.998694 63.978648 59.741997 71.648534 70.064837 53.158668 60.973961 38.136257 36.259578 55.429318 69.340292 69.000672 71.16037 60.483901 55.862601 66.854347 0.0 0.0 0.0 0.0 0.0 60.434759 20\n", "bottle2_50_ICP 54.377858 53.393512 66.12583 47.561213 51.31821 57.560825 68.805384 55.289464 73.306761 70.184317 65.496406 71.789794 67.639152 54.298582 60.46459 38.607896 35.885329 37.012867 57.479033 71.525565 0.0 0.0 0.0 0.0 0.0 57.906129 20\n", "bottle2_25_ICP 71.730017 70.795363 63.555661 67.25048 63.613194 51.285702 42.303407 39.39284 65.657843 67.373311 79.379446 51.375709 55.391288 51.114255 56.139717 53.657441 70.10359 71.862892 82.068982 67.205189 0.0 0.0 0.0 0.0 0.0 62.062816 20\n", "bottle2_0_ICP 80.541255 78.927351 86.367711 51.188665 47.259758 23.529144 26.495752 26.307019 58.988365 87.186705 94.964133 0.0 60.931521 56.640394 30.727522 30.044528 0.0 89.849671 79.279781 24.165655 94.358841 33.815192 45.865195 0.0 0.0 57.496865 21\n", "bottle2_100_FAST ICP 57.688938 58.073827 57.95261 69.895066 53.288431 52.095725 70.636632 66.160966 72.69402 72.207366 66.179926 39.479096 36.090186 51.322082 60.814999 70.445922 70.538539 72.740172 55.116972 54.539657 0.0 0.0 0.0 0.0 0.0 60.398057 20\n", "bottle2_75_FAST ICP 44.860989 67.613803 58.069773 68.358055 46.042018 64.441146 59.721992 71.641551 70.052412 53.481736 60.979005 38.131182 55.091599 55.153897 69.289835 68.607169 71.218541 59.599214 55.860476 67.014762 0.0 0.0 0.0 0.0 0.0 60.261458 20\n", "bottle2_50_FAST ICP 48.445113 53.266916 66.128142 47.394348 51.068578 57.519886 68.855187 66.043425 73.383533 70.153381 65.461271 71.790779 68.849646 54.293063 60.622404 38.606699 35.904505 36.900701 57.872143 72.136896 0.0 0.0 0.0 0.0 0.0 58.234831 20\n", "bottle2_25_FAST ICP 71.730556 70.813613 48.390064 67.208482 63.630603 51.294102 42.303407 39.394111 65.684234 67.362821 79.37104 51.333991 51.569497 51.046581 56.147149 53.361444 67.824738 71.863382 82.072543 67.188839 0.0 0.0 0.0 0.0 0.0 60.979560 20\n", "bottle2_0_FAST ICP 80.541086 78.927351 86.369584 49.968808 47.255769 23.557333 26.504626 26.359362 58.95614 87.183452 94.944673 0.0 60.904371 56.000499 30.738225 27.684303 0.0 89.849728 79.276977 22.581162 94.359098 33.984328 43.870373 0.0 0.0 57.134155 21\n", "bottle2_100_Robust ICP 50.504351 49.133166 49.608769 65.247935 42.131387 43.924281 68.181318 59.094124 67.919525 67.379707 50.458574 52.717507 34.114118 54.92686 57.805806 65.611106 61.177957 65.368603 41.45572 50.579692 0.0 0.0 0.0 0.0 0.0 54.867025 20\n", "bottle2_75_Robust ICP 65.171352 54.045867 36.901146 54.330906 47.420552 65.597031 55.602239 66.911923 67.495546 36.590494 52.79024 32.480709 50.646411 48.142464 56.953986 62.867727 57.595423 52.695511 51.982744 50.382476 0.0 0.0 0.0 0.0 0.0 53.330237 20\n", "bottle2_50_Robust ICP 47.771693 45.012185 57.661057 42.412898 44.792427 56.455638 59.622745 50.11804 57.469541 62.813152 55.040781 61.801269 59.122552 53.439211 61.519585 28.646356 55.147605 37.786525 62.005449 61.623284 0.0 0.0 0.0 0.0 0.0 53.013100 20\n", "bottle2_25_Robust ICP 68.372297 65.913029 60.802011 62.199418 62.664916 48.949447 49.991884 6.183673 49.365622 57.576716 59.482653 47.27592 61.409181 39.522688 46.994318 45.567914 57.165478 60.199405 58.092839 65.6003 0.0 0.0 0.0 0.0 0.0 53.666485 20\n", "bottle2_0_Robust ICP 64.716537 62.513045 62.81728 49.088234 45.262582 33.32966 21.138026 11.118374 47.963994 76.110225 73.256406 0.0 60.237215 77.414676 49.737045 9.669534 0.0 73.509738 69.848925 36.882767 73.228013 19.113386 47.360497 0.0 0.0 50.681722 21\n", "bottle2_100_Sparse ICP 53.412883 53.800208 52.790838 57.532525 53.838994 48.981065 62.133405 60.96027 76.258964 67.811151 60.9657 39.873357 41.373595 55.00382 59.390746 62.465343 67.976456 65.191948 52.286949 45.004554 0.0 0.0 0.0 0.0 0.0 56.852639 20\n", "bottle2_75_Sparse ICP 60.758925 62.083034 53.335445 51.852443 48.473864 57.978259 61.524882 65.698803 66.304336 58.831034 56.198062 36.067757 44.468705 56.804776 63.106554 65.245407 69.781086 65.129953 65.362751 51.36387 0.0 0.0 0.0 0.0 0.0 58.018497 20\n", "bottle2_50_Sparse ICP 63.234282 62.944344 65.182522 48.120253 52.935785 52.932735 55.108551 62.309733 76.492421 62.961988 66.740594 66.057711 64.091673 57.605262 52.913206 48.140719 39.945907 32.604047 50.441113 66.71904 0.0 0.0 0.0 0.0 0.0 57.374094 20\n", "bottle2_25_Sparse ICP 68.338245 67.504931 60.979872 57.887682 58.421357 30.656694 31.248467 43.173549 62.545731 68.838698 78.791105 53.815284 47.591621 49.769237 52.289646 57.737586 62.937188 66.062745 79.519469 57.498068 0.0 0.0 0.0 0.0 0.0 57.780359 20\n", "bottle2_0_Sparse ICP 74.964649 64.046069 72.359844 54.094445 53.676616 27.231209 23.413694 20.608975 55.196291 91.152314 82.327922 0.0 72.626788 63.141163 28.504973 23.181661 0.0 74.259527 74.642275 65.102882 82.026225 27.648789 64.4469 0.0 0.0 56.888248 21\n", "###################\n", "bottle2_100_ICP 20\n", "bottle2_75_ICP 20\n", "bottle2_50_ICP 20\n", "bottle2_25_ICP 20\n", "bottle2_0_ICP 21\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['bottle2_100_ICP':'bottle2_0_ICP', 'Counts']\n", "print(f\"###################\\n{sliced_data}\")\n", "sliced_data.to_csv(f'{category}_data_num.csv', index=True)" ] }, { "cell_type": "markdown", "id": "530262b0", "metadata": {}, "source": [] } ], "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 }