File size: 46,191 Bytes
5236ead
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
{
 "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": [
       "<bound method DataFrame.info of                          file_1 file_2 file_3 file_4 file_5 file_6 file_7  \\\n",
       "lightbulb_100_ICP           0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_75_ICP            0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_50_ICP            0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_25_ICP            0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_0_ICP             0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_100_FAST ICP      0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_75_FAST ICP       0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_50_FAST ICP       0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_25_FAST ICP       0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_0_FAST ICP        0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_100_Robust ICP    0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_75_Robust ICP     0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_50_Robust ICP     0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_25_Robust ICP     0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_0_Robust ICP      0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_100_Sparse ICP    0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_75_Sparse ICP     0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_50_Sparse ICP     0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_25_Sparse ICP     0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "lightbulb_0_Sparse ICP      0.0    0.0    0.0    0.0    0.0    0.0    0.0   \n",
       "\n",
       "                         file_8 file_9 file_10  ... file_16 file_17 file_18  \\\n",
       "lightbulb_100_ICP           0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_75_ICP            0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_50_ICP            0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_25_ICP            0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_0_ICP             0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_100_FAST ICP      0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_75_FAST ICP       0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_50_FAST ICP       0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_25_FAST ICP       0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_0_FAST ICP        0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_100_Robust ICP    0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_75_Robust ICP     0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_50_Robust ICP     0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_25_Robust ICP     0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_0_Robust ICP      0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_100_Sparse ICP    0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_75_Sparse ICP     0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_50_Sparse ICP     0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_25_Sparse ICP     0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "lightbulb_0_Sparse ICP      0.0    0.0     0.0  ...     0.0     0.0     0.0   \n",
       "\n",
       "                         file_19 file_20 file_21 file_22 file_23 file_24  \\\n",
       "lightbulb_100_ICP            0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_75_ICP             0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_50_ICP             0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_25_ICP             0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_0_ICP              0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_100_FAST ICP       0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_75_FAST ICP        0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_50_FAST ICP        0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_25_FAST ICP        0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_0_FAST ICP         0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_100_Robust ICP     0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_75_Robust ICP      0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_50_Robust ICP      0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_25_Robust ICP      0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_0_Robust ICP       0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_100_Sparse ICP     0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_75_Sparse ICP      0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_50_Sparse ICP      0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_25_Sparse ICP      0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "lightbulb_0_Sparse ICP       0.0     0.0     0.0     0.0     0.0     0.0   \n",
       "\n",
       "                         file_25  \n",
       "lightbulb_100_ICP            0.0  \n",
       "lightbulb_75_ICP             0.0  \n",
       "lightbulb_50_ICP             0.0  \n",
       "lightbulb_25_ICP             0.0  \n",
       "lightbulb_0_ICP              0.0  \n",
       "lightbulb_100_FAST ICP       0.0  \n",
       "lightbulb_75_FAST ICP        0.0  \n",
       "lightbulb_50_FAST ICP        0.0  \n",
       "lightbulb_25_FAST ICP        0.0  \n",
       "lightbulb_0_FAST ICP         0.0  \n",
       "lightbulb_100_Robust ICP     0.0  \n",
       "lightbulb_75_Robust ICP      0.0  \n",
       "lightbulb_50_Robust ICP      0.0  \n",
       "lightbulb_25_Robust ICP      0.0  \n",
       "lightbulb_0_Robust ICP       0.0  \n",
       "lightbulb_100_Sparse ICP     0.0  \n",
       "lightbulb_75_Sparse ICP      0.0  \n",
       "lightbulb_50_Sparse ICP      0.0  \n",
       "lightbulb_25_Sparse ICP      0.0  \n",
       "lightbulb_0_Sparse ICP       0.0  \n",
       "\n",
       "[20 rows x 25 columns]>"
      ]
     },
     "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",
      "<class 'pandas.core.frame.DataFrame'>\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
}