File size: 40,565 Bytes
9754890
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/satoc/miniforge3/envs/gradio/lib/python3.12/site-packages/sentence_transformers/cross_encoder/CrossEncoder.py:13: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)\n",
      "  from tqdm.autonotebook import tqdm, trange\n"
     ]
    }
   ],
   "source": [
    "from sentence_transformers import SentenceTransformer, util\n",
    "import pandas as pd\n",
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Target列を分割する関数\n",
    "def split_target(target):\n",
    "    # 指定された区切り文字で分割\n",
    "    split_words = re.split(r'[,\\n、・及びおよび又はまたは]+', target)\n",
    "    # 空白文字を除外してリストとして返す\n",
    "    return [word.strip() for word in split_words if word.strip()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "basedf = pd.read_csv('../ClinicalTrialCSV/JRCT20241202Cancer.csv', index_col=0)\n",
    "basedf = basedf.dropna(subset=['試験等のフェーズ'])\n",
    "# Target列を分割してTargetWord列を追加\n",
    "basedf['TargetWord'] = basedf['Target'].apply(split_target)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "5ae79a392bff4b6284636dc3fae01e9e",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "modules.json:   0%|          | 0.00/229 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "d77922c7458f4888b48b689b9e150b1d",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "config_sentence_transformers.json:   0%|          | 0.00/201 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "833ce903e16b40dfb4ef29a71c56f888",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "README.md:   0%|          | 0.00/9.63k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "de2121e1cd8045aabfbc47e200f069be",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "sentence_bert_config.json:   0%|          | 0.00/54.0 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "8f4b2b0060b2464282008cb21b24e77e",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "config.json:   0%|          | 0.00/975 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "7b02beb2a3624815b7a19c6f728ad3d8",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "configuration_retrieva_bert.py:   0%|          | 0.00/6.56k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "A new version of the following files was downloaded from https://huggingface.co/pkshatech/RoSEtta-base:\n",
      "- configuration_retrieva_bert.py\n",
      ". Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "3633bdeaf5bc4c389cdae1c0c3ce75a8",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "retrieva_modeling.py:   0%|          | 0.00/72.9k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "A new version of the following files was downloaded from https://huggingface.co/pkshatech/RoSEtta-base:\n",
      "- retrieva_modeling.py\n",
      ". Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "54456e42adbb4d4a834a2faa94beab6c",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "model.safetensors:   0%|          | 0.00/762M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "aeb5faf6c37640f787095938c707356c",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer_config.json:   0%|          | 0.00/2.08k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "7844a7d1ac894faead53ab8bdb3a61d0",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "tokenizer.json:   0%|          | 0.00/6.41M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "c793b2ab45f84faa8386abc875b0c153",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "special_tokens_map.json:   0%|          | 0.00/1.07k [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "932a623910b146e2b7bbf01bc8262c9d",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "1_Pooling/config.json:   0%|          | 0.00/296 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# モデルのロード\n",
    "model = SentenceTransformer(\"pkshatech/RoSEtta-base\", trust_remote_code=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "# クエリ\n",
    "#query = \"乳がん\"\n",
    "query = \"神経膠腫\"\n",
    "threshold = 0.8\n",
    "#threshold = 0.675\n",
    "# クエリをベクトル化\n",
    "query_vec = model.encode(query, convert_to_tensor=True)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>JRCT ID</th>\n",
       "      <th>NCT No</th>\n",
       "      <th>JapicCTI No</th>\n",
       "      <th>Title</th>\n",
       "      <th>Target</th>\n",
       "      <th>研究・治験の目的</th>\n",
       "      <th>試験等のフェーズ</th>\n",
       "      <th>試験の種類</th>\n",
       "      <th>無作為化</th>\n",
       "      <th>盲検化</th>\n",
       "      <th>...</th>\n",
       "      <th>purpose</th>\n",
       "      <th>Inclusion Criteria</th>\n",
       "      <th>Exclusion Criteria</th>\n",
       "      <th>Age Minimum</th>\n",
       "      <th>Age Maximum</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Discontinuation Criteria</th>\n",
       "      <th>Keyword</th>\n",
       "      <th>Intervention(s)</th>\n",
       "      <th>TargetWord</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>jRCT2051240141</td>\n",
       "      <td>NCT05580562</td>\n",
       "      <td>NaN</td>\n",
       "      <td>新たに診断され放射線療法を完了したH3 K27M変異を有するびまん性神経膠腫の治療のためのO...</td>\n",
       "      <td>H3 K27M 変異を有する初発びまん性神経膠腫</td>\n",
       "      <td>H3 K27M変異びまん性神経膠腫を有する被験者を対象に、放射線療法後に投与されたONC20...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>二重盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>1. Able to understand the study procedures and...</td>\n",
       "      <td>1. Primary spinal tumor.\\r\\n2. Diffuse intrins...</td>\n",
       "      <td>No limit</td>\n",
       "      <td>No limit</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Participants will be randomized at baseline in...</td>\n",
       "      <td>[H3 K27M 変異を有する初発, ん性神経膠腫]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>jRCT2051240121</td>\n",
       "      <td>NCT06413706</td>\n",
       "      <td>NaN</td>\n",
       "      <td>放射線療法後の悪性神経膠腫の小児および若年成人を対象に、アベマシクリブ+テモゾロミドとテモゾ...</td>\n",
       "      <td>悪性神経膠腫</td>\n",
       "      <td>放射線療法後の悪性神経膠腫を有する小児および若年成人を対象に、アベマシクリブとテモゾロミドの...</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>Subjects required to meet all the folloiwng cr...</td>\n",
       "      <td>Patients who meets any of the following criter...</td>\n",
       "      <td>No limit</td>\n",
       "      <td>21age old not</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Drug: Abemaciclib\\r\\nAdministered orally\\r\\nOt...</td>\n",
       "      <td>[悪性神経膠腫]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>224</th>\n",
       "      <td>jRCT2031240090</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>再発悪性神経膠腫に対する治療用放射性薬剤64Cu-ATSMの有効性を検証するランダム化比較医...</td>\n",
       "      <td>悪性神経膠腫</td>\n",
       "      <td>再発・難治性悪性神経膠腫を対象として、64Cu-diacetyl-bis(N4-methyl...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>1) Histologically diagnosed as high grade glio...</td>\n",
       "      <td>1) Have a history or merger of other malignanc...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>75age old under</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>glioblastoma, grade3/4 astrocytoma, grade3 oli...</td>\n",
       "      <td>Group A: BPC Therapy\\r\\nDepending on the patie...</td>\n",
       "      <td>[悪性神経膠腫]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>473</th>\n",
       "      <td>jRCT2051230069</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>神経膠腫患者に対するロムスチン療法とプロカルバジン、ロムスチン、ビンクリスチン併⽤療法の安全...</td>\n",
       "      <td>神経膠腫</td>\n",
       "      <td>神経膠腫患者におけるロムスチン療法とプロカルバジン、ロムスチン、ビンクリスチン併⽤療法の安全...</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>&lt;Cohort 1&gt;\\r\\n All of the following items shal...</td>\n",
       "      <td>&lt;Common to Cohort 1 and Cohort 2&gt;\\r\\n1) Active...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;cohort1&gt;\\r\\nLomustine 130 mg/m2 orally every ...</td>\n",
       "      <td>[神経膠腫]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>549</th>\n",
       "      <td>jRCT2031230007</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>BRAF融合遺伝子陽性の進行・再発の低悪性度神経膠腫または膵癌に対するビニメチニブの第Ⅱ相医...</td>\n",
       "      <td>低悪性度神経膠腫、膵癌</td>\n",
       "      <td>BRAF融合遺伝子または遺伝子再構成陽性の切除不能または再発の低悪性度神経膠腫(コホート A...</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>Inclusion criteria for both cohort A and B\\r\\n...</td>\n",
       "      <td>1) Active double primary cancer (but not (1)-(...</td>\n",
       "      <td>12age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>BRAF fusion gene, BRAF rearrangement, low-grad...</td>\n",
       "      <td>Binimetinib is administered 45 mg orally, twic...</td>\n",
       "      <td>[低悪性度神経膠腫, 膵癌]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>875</th>\n",
       "      <td>jRCT2031210299</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>再発悪性神経膠腫患者を対象としたDSP-0390の第1相試験</td>\n",
       "      <td>再発悪性神経膠腫</td>\n",
       "      <td>再発悪性神経膠腫患者を対象にDSP-0390を経口投与したときの安全性、薬物動態、薬力学及び...</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>1.\\tEstimated life expectancy &gt;= 3 months\\r\\n2...</td>\n",
       "      <td>1.\\tPrior therapy with bevacizumab or other an...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Patients will receive DSP-0390 orally once dai...</td>\n",
       "      <td>[再発悪性神経膠腫]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>981</th>\n",
       "      <td>jRCT2031200153</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Cellm-001による初発膠芽腫治療効果無作為比較対照試験</td>\n",
       "      <td>膠芽腫</td>\n",
       "      <td>脳腫瘍のうち、初発悪性膠芽腫に対する自家脳腫瘍免疫賦活剤であるCellm-001について、術...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>二重盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>(1) 18 years old or older and 75 years old or ...</td>\n",
       "      <td>(1) Systemic administration of corticosteroids...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>75age old under</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Inject the investigational drug (Cellm-001 or ...</td>\n",
       "      <td>[膠芽腫]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>7 rows × 39 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            JRCT ID       NCT No JapicCTI No  \\\n",
       "72   jRCT2051240141  NCT05580562         NaN   \n",
       "103  jRCT2051240121  NCT06413706         NaN   \n",
       "224  jRCT2031240090          NaN         NaN   \n",
       "473  jRCT2051230069          NaN         NaN   \n",
       "549  jRCT2031230007          NaN         NaN   \n",
       "875  jRCT2031210299          NaN         NaN   \n",
       "981  jRCT2031200153          NaN         NaN   \n",
       "\n",
       "                                                 Title  \\\n",
       "72   新たに診断され放射線療法を完了したH3 K27M変異を有するびまん性神経膠腫の治療のためのO...   \n",
       "103  放射線療法後の悪性神経膠腫の小児および若年成人を対象に、アベマシクリブ+テモゾロミドとテモゾ...   \n",
       "224  再発悪性神経膠腫に対する治療用放射性薬剤64Cu-ATSMの有効性を検証するランダム化比較医...   \n",
       "473  神経膠腫患者に対するロムスチン療法とプロカルバジン、ロムスチン、ビンクリスチン併⽤療法の安全...   \n",
       "549  BRAF融合遺伝子陽性の進行・再発の低悪性度神経膠腫または膵癌に対するビニメチニブの第Ⅱ相医...   \n",
       "875                     再発悪性神経膠腫患者を対象としたDSP-0390の第1相試験   \n",
       "981                     Cellm-001による初発膠芽腫治療効果無作為比較対照試験   \n",
       "\n",
       "                       Target  \\\n",
       "72   H3 K27M 変異を有する初発びまん性神経膠腫   \n",
       "103                    悪性神経膠腫   \n",
       "224                    悪性神経膠腫   \n",
       "473                      神経膠腫   \n",
       "549               低悪性度神経膠腫、膵癌   \n",
       "875                  再発悪性神経膠腫   \n",
       "981                       膠芽腫   \n",
       "\n",
       "                                              研究・治験の目的 試験等のフェーズ 試験の種類    無作為化  \\\n",
       "72   H3 K27M変異びまん性神経膠腫を有する被験者を対象に、放射線療法後に投与されたONC20...        3   NaN  無作為化比較   \n",
       "103  放射線療法後の悪性神経膠腫を有する小児および若年成人を対象に、アベマシクリブとテモゾロミドの...        2   NaN  無作為化比較   \n",
       "224  再発・難治性悪性神経膠腫を対象として、64Cu-diacetyl-bis(N4-methyl...        3   NaN  無作為化比較   \n",
       "473  神経膠腫患者におけるロムスチン療法とプロカルバジン、ロムスチン、ビンクリスチン併⽤療法の安全...        1   NaN     単一群   \n",
       "549  BRAF融合遺伝子または遺伝子再構成陽性の切除不能または再発の低悪性度神経膠腫(コホート A...        2   NaN     単一群   \n",
       "875  再発悪性神経膠腫患者を対象にDSP-0390を経口投与したときの安全性、薬物動態、薬力学及び...        1   NaN     単一群   \n",
       "981  脳腫瘍のうち、初発悪性膠芽腫に対する自家脳腫瘍免疫賦活剤であるCellm-001について、術...        3   NaN  無作為化比較   \n",
       "\n",
       "      盲検化  ...            purpose  \\\n",
       "72   二重盲検  ...  treatment purpose   \n",
       "103   非盲検  ...  treatment purpose   \n",
       "224   非盲検  ...  treatment purpose   \n",
       "473   非盲検  ...  treatment purpose   \n",
       "549   非盲検  ...  treatment purpose   \n",
       "875   非盲検  ...  treatment purpose   \n",
       "981  二重盲検  ...  treatment purpose   \n",
       "\n",
       "                                    Inclusion Criteria  \\\n",
       "72   1. Able to understand the study procedures and...   \n",
       "103  Subjects required to meet all the folloiwng cr...   \n",
       "224  1) Histologically diagnosed as high grade glio...   \n",
       "473  <Cohort 1>\\r\\n All of the following items shal...   \n",
       "549  Inclusion criteria for both cohort A and B\\r\\n...   \n",
       "875  1.\\tEstimated life expectancy >= 3 months\\r\\n2...   \n",
       "981  (1) 18 years old or older and 75 years old or ...   \n",
       "\n",
       "                                    Exclusion Criteria     Age Minimum  \\\n",
       "72   1. Primary spinal tumor.\\r\\n2. Diffuse intrins...        No limit   \n",
       "103  Patients who meets any of the following criter...        No limit   \n",
       "224  1) Have a history or merger of other malignanc...  18age old over   \n",
       "473  <Common to Cohort 1 and Cohort 2>\\r\\n1) Active...  18age old over   \n",
       "549  1) Active double primary cancer (but not (1)-(...  12age old over   \n",
       "875  1.\\tPrior therapy with bevacizumab or other an...  18age old over   \n",
       "981  (1) Systemic administration of corticosteroids...  18age old over   \n",
       "\n",
       "         Age Maximum Gender Discontinuation Criteria  \\\n",
       "72          No limit    NaN                      NaN   \n",
       "103    21age old not    NaN                      NaN   \n",
       "224  75age old under   Both                      NaN   \n",
       "473         No limit   Both                      NaN   \n",
       "549         No limit   Both                      NaN   \n",
       "875         No limit   Both                      NaN   \n",
       "981  75age old under   Both                      NaN   \n",
       "\n",
       "                                               Keyword  \\\n",
       "72                                                 NaN   \n",
       "103                                                NaN   \n",
       "224  glioblastoma, grade3/4 astrocytoma, grade3 oli...   \n",
       "473                                                NaN   \n",
       "549  BRAF fusion gene, BRAF rearrangement, low-grad...   \n",
       "875                                                NaN   \n",
       "981                                                NaN   \n",
       "\n",
       "                                       Intervention(s)  \\\n",
       "72   Participants will be randomized at baseline in...   \n",
       "103  Drug: Abemaciclib\\r\\nAdministered orally\\r\\nOt...   \n",
       "224  Group A: BPC Therapy\\r\\nDepending on the patie...   \n",
       "473  <cohort1>\\r\\nLomustine 130 mg/m2 orally every ...   \n",
       "549  Binimetinib is administered 45 mg orally, twic...   \n",
       "875  Patients will receive DSP-0390 orally once dai...   \n",
       "981  Inject the investigational drug (Cellm-001 or ...   \n",
       "\n",
       "                     TargetWord  \n",
       "72   [H3 K27M 変異を有する初発, ん性神経膠腫]  \n",
       "103                    [悪性神経膠腫]  \n",
       "224                    [悪性神経膠腫]  \n",
       "473                      [神経膠腫]  \n",
       "549              [低悪性度神経膠腫, 膵癌]  \n",
       "875                  [再発悪性神経膠腫]  \n",
       "981                       [膠芽腫]  \n",
       "\n",
       "[7 rows x 39 columns]"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# ターゲットリスト全体を処理\n",
    "matched_indices = []\n",
    "target_vecs_list = []\n",
    "cosine_scores_list = []\n",
    "for idx, target_words in enumerate(basedf['TargetWord']):\n",
    "    # ターゲット内の各単語をベクトル化\n",
    "    target_vecs = model.encode(target_words, convert_to_tensor=True)\n",
    "    # コサイン類似度を計算\n",
    "    cosine_scores = util.cos_sim(query_vec, target_vecs).squeeze()\n",
    "    target_vecs_list.append(target_vecs)\n",
    "    cosine_scores_list.append(cosine_scores)\n",
    "    # 閾値を超えるか確認\n",
    "    if (cosine_scores >= threshold).any():  # いずれかが閾値を超えている場合\n",
    "        matched_indices.append(idx)\n",
    "\n",
    "# 抽出\n",
    "matched_df = basedf.iloc[matched_indices]\n",
    "matched_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 全データのターゲット列をベクトル化\n",
    "target_list = basedf['Target'].tolist()\n",
    "target_vecs = model.encode(target_list, convert_to_tensor=True)\n",
    "# コサイン類似度を計算\n",
    "cosine_scores = util.cos_sim(query_vec, target_vecs).squeeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>JRCT ID</th>\n",
       "      <th>NCT No</th>\n",
       "      <th>JapicCTI No</th>\n",
       "      <th>Title</th>\n",
       "      <th>Target</th>\n",
       "      <th>研究・治験の目的</th>\n",
       "      <th>試験等のフェーズ</th>\n",
       "      <th>試験の種類</th>\n",
       "      <th>無作為化</th>\n",
       "      <th>盲検化</th>\n",
       "      <th>...</th>\n",
       "      <th>purpose</th>\n",
       "      <th>Inclusion Criteria</th>\n",
       "      <th>Exclusion Criteria</th>\n",
       "      <th>Age Minimum</th>\n",
       "      <th>Age Maximum</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Discontinuation Criteria</th>\n",
       "      <th>Keyword</th>\n",
       "      <th>Intervention(s)</th>\n",
       "      <th>TargetWord</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>jRCT2051240121</td>\n",
       "      <td>NCT06413706</td>\n",
       "      <td>NaN</td>\n",
       "      <td>放射線療法後の悪性神経膠腫の小児および若年成人を対象に、アベマシクリブ+テモゾロミドとテモゾ...</td>\n",
       "      <td>悪性神経膠腫</td>\n",
       "      <td>放射線療法後の悪性神経膠腫を有する小児および若年成人を対象に、アベマシクリブとテモゾロミドの...</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>Subjects required to meet all the folloiwng cr...</td>\n",
       "      <td>Patients who meets any of the following criter...</td>\n",
       "      <td>No limit</td>\n",
       "      <td>21age old not</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Drug: Abemaciclib\\r\\nAdministered orally\\r\\nOt...</td>\n",
       "      <td>[悪性神経膠腫]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>224</th>\n",
       "      <td>jRCT2031240090</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>再発悪性神経膠腫に対する治療用放射性薬剤64Cu-ATSMの有効性を検証するランダム化比較医...</td>\n",
       "      <td>悪性神経膠腫</td>\n",
       "      <td>再発・難治性悪性神経膠腫を対象として、64Cu-diacetyl-bis(N4-methyl...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>1) Histologically diagnosed as high grade glio...</td>\n",
       "      <td>1) Have a history or merger of other malignanc...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>75age old under</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>glioblastoma, grade3/4 astrocytoma, grade3 oli...</td>\n",
       "      <td>Group A: BPC Therapy\\r\\nDepending on the patie...</td>\n",
       "      <td>[悪性神経膠腫]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>473</th>\n",
       "      <td>jRCT2051230069</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>神経膠腫患者に対するロムスチン療法とプロカルバジン、ロムスチン、ビンクリスチン併⽤療法の安全...</td>\n",
       "      <td>神経膠腫</td>\n",
       "      <td>神経膠腫患者におけるロムスチン療法とプロカルバジン、ロムスチン、ビンクリスチン併⽤療法の安全...</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>&lt;Cohort 1&gt;\\r\\n All of the following items shal...</td>\n",
       "      <td>&lt;Common to Cohort 1 and Cohort 2&gt;\\r\\n1) Active...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;cohort1&gt;\\r\\nLomustine 130 mg/m2 orally every ...</td>\n",
       "      <td>[神経膠腫]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>875</th>\n",
       "      <td>jRCT2031210299</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>再発悪性神経膠腫患者を対象としたDSP-0390の第1相試験</td>\n",
       "      <td>再発悪性神経膠腫</td>\n",
       "      <td>再発悪性神経膠腫患者を対象にDSP-0390を経口投与したときの安全性、薬物動態、薬力学及び...</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>単一群</td>\n",
       "      <td>非盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>1.\\tEstimated life expectancy &gt;= 3 months\\r\\n2...</td>\n",
       "      <td>1.\\tPrior therapy with bevacizumab or other an...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>No limit</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Patients will receive DSP-0390 orally once dai...</td>\n",
       "      <td>[再発悪性神経膠腫]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>981</th>\n",
       "      <td>jRCT2031200153</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Cellm-001による初発膠芽腫治療効果無作為比較対照試験</td>\n",
       "      <td>膠芽腫</td>\n",
       "      <td>脳腫瘍のうち、初発悪性膠芽腫に対する自家脳腫瘍免疫賦活剤であるCellm-001について、術...</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>無作為化比較</td>\n",
       "      <td>二重盲検</td>\n",
       "      <td>...</td>\n",
       "      <td>treatment purpose</td>\n",
       "      <td>(1) 18 years old or older and 75 years old or ...</td>\n",
       "      <td>(1) Systemic administration of corticosteroids...</td>\n",
       "      <td>18age old over</td>\n",
       "      <td>75age old under</td>\n",
       "      <td>Both</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Inject the investigational drug (Cellm-001 or ...</td>\n",
       "      <td>[膠芽腫]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 39 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            JRCT ID       NCT No JapicCTI No  \\\n",
       "103  jRCT2051240121  NCT06413706         NaN   \n",
       "224  jRCT2031240090          NaN         NaN   \n",
       "473  jRCT2051230069          NaN         NaN   \n",
       "875  jRCT2031210299          NaN         NaN   \n",
       "981  jRCT2031200153          NaN         NaN   \n",
       "\n",
       "                                                 Title    Target  \\\n",
       "103  放射線療法後の悪性神経膠腫の小児および若年成人を対象に、アベマシクリブ+テモゾロミドとテモゾ...    悪性神経膠腫   \n",
       "224  再発悪性神経膠腫に対する治療用放射性薬剤64Cu-ATSMの有効性を検証するランダム化比較医...    悪性神経膠腫   \n",
       "473  神経膠腫患者に対するロムスチン療法とプロカルバジン、ロムスチン、ビンクリスチン併⽤療法の安全...      神経膠腫   \n",
       "875                     再発悪性神経膠腫患者を対象としたDSP-0390の第1相試験  再発悪性神経膠腫   \n",
       "981                     Cellm-001による初発膠芽腫治療効果無作為比較対照試験       膠芽腫   \n",
       "\n",
       "                                              研究・治験の目的 試験等のフェーズ 試験の種類    無作為化  \\\n",
       "103  放射線療法後の悪性神経膠腫を有する小児および若年成人を対象に、アベマシクリブとテモゾロミドの...        2   NaN  無作為化比較   \n",
       "224  再発・難治性悪性神経膠腫を対象として、64Cu-diacetyl-bis(N4-methyl...        3   NaN  無作為化比較   \n",
       "473  神経膠腫患者におけるロムスチン療法とプロカルバジン、ロムスチン、ビンクリスチン併⽤療法の安全...        1   NaN     単一群   \n",
       "875  再発悪性神経膠腫患者を対象にDSP-0390を経口投与したときの安全性、薬物動態、薬力学及び...        1   NaN     単一群   \n",
       "981  脳腫瘍のうち、初発悪性膠芽腫に対する自家脳腫瘍免疫賦活剤であるCellm-001について、術...        3   NaN  無作為化比較   \n",
       "\n",
       "      盲検化  ...            purpose  \\\n",
       "103   非盲検  ...  treatment purpose   \n",
       "224   非盲検  ...  treatment purpose   \n",
       "473   非盲検  ...  treatment purpose   \n",
       "875   非盲検  ...  treatment purpose   \n",
       "981  二重盲検  ...  treatment purpose   \n",
       "\n",
       "                                    Inclusion Criteria  \\\n",
       "103  Subjects required to meet all the folloiwng cr...   \n",
       "224  1) Histologically diagnosed as high grade glio...   \n",
       "473  <Cohort 1>\\r\\n All of the following items shal...   \n",
       "875  1.\\tEstimated life expectancy >= 3 months\\r\\n2...   \n",
       "981  (1) 18 years old or older and 75 years old or ...   \n",
       "\n",
       "                                    Exclusion Criteria     Age Minimum  \\\n",
       "103  Patients who meets any of the following criter...        No limit   \n",
       "224  1) Have a history or merger of other malignanc...  18age old over   \n",
       "473  <Common to Cohort 1 and Cohort 2>\\r\\n1) Active...  18age old over   \n",
       "875  1.\\tPrior therapy with bevacizumab or other an...  18age old over   \n",
       "981  (1) Systemic administration of corticosteroids...  18age old over   \n",
       "\n",
       "         Age Maximum Gender Discontinuation Criteria  \\\n",
       "103    21age old not    NaN                      NaN   \n",
       "224  75age old under   Both                      NaN   \n",
       "473         No limit   Both                      NaN   \n",
       "875         No limit   Both                      NaN   \n",
       "981  75age old under   Both                      NaN   \n",
       "\n",
       "                                               Keyword  \\\n",
       "103                                                NaN   \n",
       "224  glioblastoma, grade3/4 astrocytoma, grade3 oli...   \n",
       "473                                                NaN   \n",
       "875                                                NaN   \n",
       "981                                                NaN   \n",
       "\n",
       "                                       Intervention(s)  TargetWord  \n",
       "103  Drug: Abemaciclib\\r\\nAdministered orally\\r\\nOt...    [悪性神経膠腫]  \n",
       "224  Group A: BPC Therapy\\r\\nDepending on the patie...    [悪性神経膠腫]  \n",
       "473  <cohort1>\\r\\nLomustine 130 mg/m2 orally every ...      [神経膠腫]  \n",
       "875  Patients will receive DSP-0390 orally once dai...  [再発悪性神経膠腫]  \n",
       "981  Inject the investigational drug (Cellm-001 or ...       [膠芽腫]  \n",
       "\n",
       "[5 rows x 39 columns]"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "matched_indices_d = (cosine_scores >= threshold).nonzero().tolist()\n",
    "# 入れ子リストをフラットなリストに変換\n",
    "flat_indices_d = [idx[0] for idx in matched_indices_d]\n",
    "\n",
    "# 抽出\n",
    "matched_df_d = basedf.iloc[flat_indices_d]\n",
    "matched_df_d\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "gradio",
   "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.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}