Skip to content
Snippets Groups Projects
Commit 97dc77aa authored by Arthur Batel's avatar Arthur Batel
Browse files

Explainations

parent de8e2df7
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:b0ab105c19fde634 tags:
 
``` python
path = "./"
datasets = ['assist09_tkde', 'assist17_tkde', 'algebra','math_1', 'math_2']
```
 
%% Cell type:markdown id:841ae3856df97ef0 tags:
 
## Table 2 and 3: compute ACC, AUC and RMSE and DOA
 
Warning : can be long to compute
Prerequisite : Running the makefile
Output : stored in `../../results/table_2`
**Warning** : can be long to compute
**Prerequisite** : Running the makefile
**Output** : stored in `../../results/table_2`
 
%% Cell type:code id:f361888d67da2988 tags:
 
``` python
import os
 
cmd = 'cd code/binary_bpr && python ./script.py '
!{cmd}
```
 
%% Cell type:markdown id:d8116396a802bc7d tags:
 
## Table 3: compute DOA
 
**Warning** : can be long to compute
**Prerequisite** : Running the makefile
**Output** : printed in the notebook
The doa metrics are computed for the dataset whose index is specified by the variable `i`, for CD-BPR and for all competitors simultaneously, and for each data splitting of the cross validation.
The embeddings are given pre-computed in the `result` directory. However, for the sake of reproducibility, they will be overwritten by the ones computed in the previous cell.
%% Cell type:code id:68a2dc1287b5cac tags:
 
``` python
import os
embDirPath = "../../results/table_2/users/"
 
i=3 # dataset indice
 
cmd = 'cd code/ && python ./DOA.py --datasetName '+datasets[i]
!{cmd}
```
 
%% Output
 
_create_directory() - handled error when creating a directory at ../experiments_logs/3: [Errno 17] File exists: '../experiments_logs/3'
dataset math_1
fold 0
model DINA
num_kc 11
model MCD
num_kc 11
model NCDM
num_kc 11
model MIRT
num_kc 11
model BPR
num_kc 11
fold 1
model DINA
num_kc 11
model MCD
num_kc 11
model NCDM
num_kc 11
^C
Traceback (most recent call last):
File "/home/arthurb/Programmation/cd-bpr/code/./DOA.py", line 161, in <module>
exp.train_test_split(dataset_name, test_proportion=0.2, valid_proportion=0.2, n_folds=5, i_fold=i_fold)
File "/home/arthurb/Programmation/cd-bpr/code/utility/DatasetProcessor.py", line 938, in train_test_split
self.test_steps[dataset_name] = self.get_test_dataset(dataset_name=dataset_name)['train_valid_log_nb'].to_numpy().astype(int)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/Programmation/cd-bpr/code/utility/DatasetProcessor.py", line 1416, in get_test_dataset
return self.datasets[dataset_name][self.datasets[dataset_name]['split']=='test']
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/ops/common.py", line 76, in new_method
return method(self, other)
^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/arraylike.py", line 40, in __eq__
return self._cmp_method(other, operator.eq)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/series.py", line 5803, in _cmp_method
res_values = ops.comparison_op(lvalues, rvalues, op)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/ops/array_ops.py", line 346, in comparison_op
res_values = comp_method_OBJECT_ARRAY(op, lvalues, rvalues)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/ops/array_ops.py", line 131, in comp_method_OBJECT_ARRAY
result = libops.scalar_compare(x.ravel(), y, op)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/Programmation/cd-bpr/code/./DOA.py", line 185, in <module>
r_train = dao_creuse(F, kc_user, kc_user_val, dico_u)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/Programmation/cd-bpr/code/./DOA.py", line -1, in dao_creuse
KeyboardInterrupt
 
%% Cell type:markdown id:8d5630b5 tags:
 
## Table 4: ablation
 
%% Cell type:code id:a9e32954 tags:
 
``` python
import os
cmd = 'cd code/binary_bpr_ablation && python script_ablation.py '
!{cmd}
```
 
%% Output
 
Ablation (0 no ablation, 1 ablation L2, 2 ablation init, 3 both) 0
assist0910_tkde
NB (question-answer) in the data 17283
Epoch 1, Loss: 1.37166428565979
Epoch 1, Loss: 1.3824448585510254
^C
Traceback (most recent call last):
File "/home/arthurb/Programmation/cd-bpr/code/binary_bpr_ablation/main.py", line 219, in <module>
acc = bpr_model.train(train, len(dico_kc), epochs, batch_size, y_train, ablation)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/Programmation/cd-bpr/code/binary_bpr_ablation/BPR_model.py", line 105, in train
self.optimizer.step()
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/torch/optim/optimizer.py", line 385, in wrapper
out = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/torch/optim/optimizer.py", line 76, in _use_grad
ret = func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/torch/optim/adam.py", line 166, in step
adam(
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/torch/optim/adam.py", line 316, in adam
func(params,
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/torch/optim/adam.py", line 391, in _single_tensor_adam
exp_avg.lerp_(grad, 1 - beta1)
File "/home/arthurb/Programmation/cd-bpr/code/binary_bpr_ablation/BPR_model.py", line 99, in train
comp = comp.cpu()
^^^^^^^^^^
KeyboardInterrupt
 
%% Cell type:markdown id:c5960372 tags:
 
## Table 6
 
%% Cell type:code id:e46ff5d4 tags:
 
``` python
# pour all
cmd = 'python code/nary_model/main_nary_cv.py --data '+ path+'data/covid/initsurvey.csv'
print(os.system(cmd))
cmd = 'python code/nary_model/main_nary_cv.py --data '+path+'data/covid/psysurvey.csv'
print(os.system(cmd))
```
 
%% Output
 
Error: mkl-service + Intel(R) MKL: MKL_THREADING_LAYER=INTEL is incompatible with libgomp.so.1 library.
Try to import numpy first or set the threading layer accordingly. Set MKL_SERVICE_FORCE_INTEL to force it.
 
256
256
 
Error: mkl-service + Intel(R) MKL: MKL_THREADING_LAYER=INTEL is incompatible with libgomp.so.1 library.
Try to import numpy first or set the threading layer accordingly. Set MKL_SERVICE_FORCE_INTEL to force it.
 
%% Cell type:markdown id:e586f5cb tags:
 
## Figure 1 and Table 7
 
%% Cell type:code id:4c4b8106 tags:
 
``` python
cmd = 'python code/unsupervised_DT/decision_tree.py --lower 0'
print(os.system(cmd))
cmd = 'python code/unsupervised_DT/decision_tree.py --lower 1'
print(os.system(cmd))
```
 
%% Output
 
/home/arthurb/Programmation/cd-bpr/code/unsupervised_DT/files_for_dt/train_embed.csv
| --- feature_3 <= 0.55
| | --- feature_9 <= -0.07
| | | --- cluster 0 (151)
| | --- feature_9 > -0.07
| | | --- feature_15 <= -0.30
| | | | --- cluster 1 (111)
| | | --- feature_15 > -0.30
| | | | --- feature_10 <= -0.25
| | | | | --- cluster 2 (57)
| | | | --- feature_10 > -0.25
| | | | | --- cluster 3 (415)
| --- feature_3 > 0.55
| | --- feature_8 <= 0.35
| | | --- cluster 4 (110)
| | --- feature_8 > 0.35
| | | --- cluster 5 (73)
(array([ 7, 14, 20, 22, 23, 39, 44, 53, 56, 57, 62, 71, 95,
100, 106, 119, 122, 133, 141, 142, 152, 154, 156, 160, 179, 182,
183, 187, 188, 191, 194, 198, 199, 201, 203, 207, 208, 214, 219,
221, 224, 233, 235, 241, 243, 246, 252, 259, 261, 265, 266, 267,
271, 282, 289, 293, 299, 302, 303, 304, 307, 308, 309, 310, 312,
313, 325, 327, 351, 358, 385, 390, 393, 396, 406, 409, 415, 419,
431, 435, 445, 447, 448, 450, 468, 479, 486, 488, 490, 494, 510,
516, 517, 525, 546, 547, 550, 551, 553, 557, 559, 565, 567, 578,
580, 597, 600, 604, 608, 611, 612, 615, 640, 641, 644, 656, 662,
677, 679, 682, 686, 688, 690, 703, 709, 714, 723, 732, 745, 752,
776, 782, 785, 786, 787, 789, 792, 798, 810, 829, 839, 842, 844,
847, 854, 866, 869, 870, 881, 883, 900]),)
(array([ 4, 8, 15, 28, 40, 41, 42, 50, 59, 84, 85, 88, 89,
109, 112, 123, 138, 145, 146, 150, 157, 158, 166, 181, 186, 190,
232, 234, 242, 247, 248, 249, 260, 272, 274, 277, 281, 296, 301,
338, 339, 345, 352, 359, 365, 388, 403, 404, 412, 418, 441, 443,
461, 464, 478, 481, 489, 491, 495, 497, 500, 508, 524, 531, 569,
576, 587, 589, 609, 610, 613, 617, 620, 622, 627, 637, 642, 647,
673, 678, 711, 712, 715, 720, 726, 729, 730, 758, 759, 760, 788,
797, 811, 815, 819, 820, 821, 830, 831, 840, 845, 849, 862, 878,
880, 884, 891, 895, 898, 904, 906]),)
(array([ 58, 75, 80, 103, 114, 161, 205, 210, 211, 226, 227, 236, 244,
257, 258, 328, 347, 356, 357, 372, 380, 391, 399, 400, 402, 410,
455, 457, 526, 558, 583, 606, 614, 616, 618, 624, 643, 645, 660,
664, 676, 691, 717, 738, 755, 756, 763, 771, 796, 812, 817, 832,
850, 861, 868, 882, 912]),)
(array([ 0, 2, 3, 5, 6, 9, 10, 11, 12, 17, 18, 24, 29,
30, 31, 32, 33, 34, 35, 36, 38, 43, 46, 48, 52, 54,
55, 63, 64, 66, 68, 69, 72, 74, 76, 77, 78, 79, 81,
82, 87, 90, 91, 92, 93, 94, 98, 99, 101, 102, 104, 105,
107, 108, 110, 111, 115, 117, 120, 121, 124, 126, 127, 129, 130,
131, 132, 134, 135, 136, 137, 139, 143, 144, 148, 149, 151, 155,
163, 167, 171, 172, 173, 175, 176, 177, 178, 184, 189, 192, 193,
195, 196, 197, 200, 202, 204, 206, 215, 218, 222, 223, 225, 229,
230, 237, 238, 240, 251, 253, 254, 256, 262, 263, 264, 268, 273,
278, 279, 280, 283, 284, 287, 288, 290, 291, 292, 294, 295, 305,
306, 315, 317, 318, 319, 320, 321, 322, 323, 324, 330, 331, 332,
333, 334, 336, 337, 340, 342, 343, 346, 350, 353, 354, 355, 360,
361, 363, 364, 366, 367, 368, 370, 371, 373, 374, 376, 382, 383,
386, 389, 392, 394, 397, 401, 407, 411, 413, 414, 416, 417, 423,
424, 425, 426, 427, 428, 429, 432, 434, 437, 438, 440, 442, 444,
446, 449, 453, 454, 456, 458, 459, 462, 467, 469, 471, 472, 473,
475, 477, 480, 482, 483, 484, 485, 492, 493, 496, 498, 499, 502,
504, 506, 507, 509, 513, 515, 518, 519, 520, 521, 522, 523, 527,
528, 529, 530, 532, 533, 534, 535, 536, 537, 538, 539, 541, 542,
543, 544, 545, 549, 552, 556, 560, 561, 562, 563, 566, 570, 571,
573, 574, 575, 577, 581, 582, 585, 588, 591, 592, 593, 594, 595,
596, 598, 599, 601, 602, 603, 605, 607, 619, 623, 625, 626, 628,
629, 630, 631, 632, 635, 638, 639, 648, 649, 650, 651, 652, 654,
657, 663, 667, 668, 669, 670, 672, 675, 681, 683, 684, 692, 693,
694, 695, 697, 698, 700, 704, 705, 706, 707, 708, 710, 713, 716,
718, 719, 722, 724, 727, 728, 731, 733, 734, 735, 736, 737, 740,
741, 744, 747, 748, 749, 750, 751, 754, 757, 762, 764, 765, 767,
768, 770, 772, 773, 774, 775, 777, 778, 779, 780, 781, 783, 791,
793, 795, 799, 800, 801, 802, 803, 804, 806, 808, 816, 818, 822,
823, 824, 825, 826, 833, 836, 837, 838, 841, 846, 848, 851, 852,
856, 857, 864, 873, 875, 877, 885, 886, 887, 888, 889, 890, 893,
894, 896, 897, 899, 901, 902, 903, 905, 907, 909, 911, 914]),)
(array([ 13, 16, 19, 27, 37, 47, 49, 60, 61, 65, 67, 70, 73,
83, 86, 125, 128, 140, 147, 153, 159, 162, 165, 168, 170, 185,
209, 228, 239, 245, 250, 269, 270, 275, 285, 300, 311, 314, 316,
329, 341, 348, 349, 362, 369, 375, 377, 378, 379, 384, 395, 398,
408, 433, 439, 452, 465, 466, 470, 487, 501, 503, 514, 540, 548,
554, 555, 564, 568, 572, 584, 590, 634, 653, 655, 658, 659, 661,
665, 666, 671, 674, 696, 699, 702, 721, 739, 742, 746, 753, 769,
784, 790, 794, 809, 813, 827, 828, 843, 853, 855, 858, 859, 860,
865, 867, 874, 908, 915, 916]),)
Purity: 0.8255179934569248
0
/home/arthurb/Programmation/cd-bpr/code/unsupervised_DT/files_for_dt/train_embed.csv
| --- feature_3 <= 0.55
| | --- feature_9 <= -0.07
| | | --- cluster 0 (151)
| | --- feature_9 > -0.07
| | | --- feature_15 <= -0.30
| | | | --- cluster 1 (111)
| | | --- feature_15 > -0.30
| | | | --- feature_10 <= -0.25
| | | | | --- cluster 2 (57)
| | | | --- feature_10 > -0.25
| | | | | --- cluster 3 (415)
| --- feature_3 > 0.55
| | --- feature_8 <= 0.35
| | | --- cluster 4 (110)
| | --- feature_8 > 0.35
| | | --- cluster 5 (73)
(array([ 7, 14, 20, 22, 23, 39, 44, 53, 56, 57, 62, 71, 95,
100, 106, 119, 122, 133, 141, 142, 152, 154, 156, 160, 179, 182,
183, 187, 188, 191, 194, 198, 199, 201, 203, 207, 208, 214, 219,
221, 224, 233, 235, 241, 243, 246, 252, 259, 261, 265, 266, 267,
271, 282, 289, 293, 299, 302, 303, 304, 307, 308, 309, 310, 312,
313, 325, 327, 351, 358, 385, 390, 393, 396, 406, 409, 415, 419,
431, 435, 445, 447, 448, 450, 468, 479, 486, 488, 490, 494, 510,
516, 517, 525, 546, 547, 550, 551, 553, 557, 559, 565, 567, 578,
580, 597, 600, 604, 608, 611, 612, 615, 640, 641, 644, 656, 662,
677, 679, 682, 686, 688, 690, 703, 709, 714, 723, 732, 745, 752,
776, 782, 785, 786, 787, 789, 792, 798, 810, 829, 839, 842, 844,
847, 854, 866, 869, 870, 881, 883, 900]),)
(array([ 4, 8, 15, 28, 40, 41, 42, 50, 59, 84, 85, 88, 89,
109, 112, 123, 138, 145, 146, 150, 157, 158, 166, 181, 186, 190,
232, 234, 242, 247, 248, 249, 260, 272, 274, 277, 281, 296, 301,
338, 339, 345, 352, 359, 365, 388, 403, 404, 412, 418, 441, 443,
461, 464, 478, 481, 489, 491, 495, 497, 500, 508, 524, 531, 569,
576, 587, 589, 609, 610, 613, 617, 620, 622, 627, 637, 642, 647,
673, 678, 711, 712, 715, 720, 726, 729, 730, 758, 759, 760, 788,
797, 811, 815, 819, 820, 821, 830, 831, 840, 845, 849, 862, 878,
880, 884, 891, 895, 898, 904, 906]),)
(array([ 58, 75, 80, 103, 114, 161, 205, 210, 211, 226, 227, 236, 244,
257, 258, 328, 347, 356, 357, 372, 380, 391, 399, 400, 402, 410,
455, 457, 526, 558, 583, 606, 614, 616, 618, 624, 643, 645, 660,
664, 676, 691, 717, 738, 755, 756, 763, 771, 796, 812, 817, 832,
850, 861, 868, 882, 912]),)
(array([ 0, 2, 3, 5, 6, 9, 10, 11, 12, 17, 18, 24, 29,
30, 31, 32, 33, 34, 35, 36, 38, 43, 46, 48, 52, 54,
55, 63, 64, 66, 68, 69, 72, 74, 76, 77, 78, 79, 81,
82, 87, 90, 91, 92, 93, 94, 98, 99, 101, 102, 104, 105,
107, 108, 110, 111, 115, 117, 120, 121, 124, 126, 127, 129, 130,
131, 132, 134, 135, 136, 137, 139, 143, 144, 148, 149, 151, 155,
163, 167, 171, 172, 173, 175, 176, 177, 178, 184, 189, 192, 193,
195, 196, 197, 200, 202, 204, 206, 215, 218, 222, 223, 225, 229,
230, 237, 238, 240, 251, 253, 254, 256, 262, 263, 264, 268, 273,
278, 279, 280, 283, 284, 287, 288, 290, 291, 292, 294, 295, 305,
306, 315, 317, 318, 319, 320, 321, 322, 323, 324, 330, 331, 332,
333, 334, 336, 337, 340, 342, 343, 346, 350, 353, 354, 355, 360,
361, 363, 364, 366, 367, 368, 370, 371, 373, 374, 376, 382, 383,
386, 389, 392, 394, 397, 401, 407, 411, 413, 414, 416, 417, 423,
424, 425, 426, 427, 428, 429, 432, 434, 437, 438, 440, 442, 444,
446, 449, 453, 454, 456, 458, 459, 462, 467, 469, 471, 472, 473,
475, 477, 480, 482, 483, 484, 485, 492, 493, 496, 498, 499, 502,
504, 506, 507, 509, 513, 515, 518, 519, 520, 521, 522, 523, 527,
528, 529, 530, 532, 533, 534, 535, 536, 537, 538, 539, 541, 542,
543, 544, 545, 549, 552, 556, 560, 561, 562, 563, 566, 570, 571,
573, 574, 575, 577, 581, 582, 585, 588, 591, 592, 593, 594, 595,
596, 598, 599, 601, 602, 603, 605, 607, 619, 623, 625, 626, 628,
629, 630, 631, 632, 635, 638, 639, 648, 649, 650, 651, 652, 654,
657, 663, 667, 668, 669, 670, 672, 675, 681, 683, 684, 692, 693,
694, 695, 697, 698, 700, 704, 705, 706, 707, 708, 710, 713, 716,
718, 719, 722, 724, 727, 728, 731, 733, 734, 735, 736, 737, 740,
741, 744, 747, 748, 749, 750, 751, 754, 757, 762, 764, 765, 767,
768, 770, 772, 773, 774, 775, 777, 778, 779, 780, 781, 783, 791,
793, 795, 799, 800, 801, 802, 803, 804, 806, 808, 816, 818, 822,
823, 824, 825, 826, 833, 836, 837, 838, 841, 846, 848, 851, 852,
856, 857, 864, 873, 875, 877, 885, 886, 887, 888, 889, 890, 893,
894, 896, 897, 899, 901, 902, 903, 905, 907, 909, 911, 914]),)
(array([ 13, 16, 19, 27, 37, 47, 49, 60, 61, 65, 67, 70, 73,
83, 86, 125, 128, 140, 147, 153, 159, 162, 165, 168, 170, 185,
209, 228, 239, 245, 250, 269, 270, 275, 285, 300, 311, 314, 316,
329, 341, 348, 349, 362, 369, 375, 377, 378, 379, 384, 395, 398,
408, 433, 439, 452, 465, 466, 470, 487, 501, 503, 514, 540, 548,
554, 555, 564, 568, 572, 584, 590, 634, 653, 655, 658, 659, 661,
665, 666, 671, 674, 696, 699, 702, 721, 739, 742, 746, 753, 769,
784, 790, 794, 809, 813, 827, 828, 843, 853, 855, 858, 859, 860,
865, 867, 874, 908, 915, 916]),)
Purity: 0.5986913849509269
0
 
%% Cell type:markdown id:f39f6de3 tags:
 
## Figure 2: radar plots --
 
%% Cell type:code id:ceee0ec4 tags:
 
``` python
def fromDFtoArray(name, vector, type_value):
# Read dataframe and generate a matrix or
# a vector of appropriate type
df = pd.read_csv(name,index_col=None, header=None)
cols = df.columns
if(type_value == "f"):
for col in cols:
df[col] = df[col].astype(float)
if(type_value == 'i'):
for col in cols:
df[col] = df[col].astype(int)
r = df.values
if(vector):
r = r.reshape(-1,)
return r
```
 
%% Cell type:code id:801e2ab1 tags:
 
``` python
from sklearn.preprocessing import MinMaxScaler
import plotly.graph_objects as go
import pandas as pd
import numpy as np
import csv
from matplotlib import gridspec
import seaborn as sns
import matplotlib.pyplot as plt
```
 
%% Cell type:code id:5a8b764b tags:
 
``` python
H_users = fromDFtoArray(path+ "code/unsupervised_DT/files_for_dt/train_embed.csv",False,'f')
classPsy = fromDFtoArray(path+ "code/unsupervised_DT/files_for_dt/train_user_quest_label.csv",False,'f')
```
 
%% Cell type:code id:33643887 tags:
 
``` python
d = [151,111,57,415,110,73]
g = [[7, 14, 20, 22, 23, 39, 44, 53, 56, 57, 62, 71, 95, 100, 106, 119, 122, 133, 141, 142, 152, 154, 156, 160, 179, 182, 183, 187, 188, 191, 194, 198, 199, 201, 203, 207, 208, 214, 219, 221, 224, 233, 235, 241, 243, 246, 252, 259, 261, 265, 266, 267, 271, 282, 289, 293, 299, 302, 303, 304, 307, 308, 309, 310, 312, 313, 325, 327, 351, 358, 385, 390, 393, 396, 406, 409, 415, 419, 431, 435, 445, 447, 448, 450, 468, 479, 486, 488, 490, 494, 510, 516, 517, 525, 546, 547, 550, 551, 553, 557, 559, 565, 567, 578, 580, 597, 600, 604, 608, 611, 612, 615, 640, 641, 644, 656, 662, 677, 679, 682, 686, 688, 690, 703, 709, 714, 723, 732, 745, 752, 776, 782, 785, 786, 787, 789, 792, 798, 810, 829, 839, 842, 844, 847, 854, 866, 869, 870, 881, 883, 900]
, [4, 8, 15, 28, 40, 41, 42, 50, 59, 84, 85, 88, 89, 109, 112, 123, 138, 145, 146, 150, 157, 158, 166, 181, 186, 190, 232, 234, 242, 247, 248, 249, 260, 272, 274, 277, 281, 296, 301, 338, 339, 345, 352, 359, 365, 388, 403, 404, 412, 418, 441, 443, 461, 464, 478, 481, 489, 491, 495, 497, 500, 508, 524, 531, 569, 576, 587, 589, 609, 610, 613, 617, 620, 622, 627, 637, 642, 647, 673, 678, 711, 712, 715, 720, 726, 729, 730, 758, 759, 760, 788, 797, 811, 815, 819, 820, 821, 830, 831, 840, 845, 849, 862, 878, 880, 884, 891, 895, 898, 904, 906 ]
,[58, 75, 80, 103, 114, 161, 205, 210, 211, 226, 227, 236, 244, 257, 258, 328, 347, 356, 357, 372, 380, 391, 399, 400, 402, 410, 455, 457, 526, 558, 583, 606, 614, 616, 618, 624, 643, 645, 660, 664, 676, 691, 717, 738, 755, 756, 763, 771, 796, 812, 817, 832, 850, 861, 868, 882, 912]
,[0, 2, 3, 5, 6, 9, 10, 11, 12, 17, 18, 24, 29, 30, 31, 32, 33, 34, 35, 36, 38, 43, 46, 48, 52, 54, 55, 63, 64, 66, 68, 69, 72, 74, 76, 77, 78, 79, 81, 82, 87, 90, 91, 92, 93, 94, 98, 99, 101, 102, 104, 105, 107, 108, 110, 111, 115, 117, 120, 121, 124, 126, 127, 129, 130, 131, 132, 134, 135, 136, 137, 139, 143, 144, 148, 149, 151, 155, 163, 167, 171, 172, 173, 175, 176, 177, 178, 184, 189, 192, 193, 195, 196, 197, 200, 202, 204, 206, 215, 218, 222, 223, 225, 229, 230, 237, 238, 240, 251, 253, 254, 256, 262, 263, 264, 268, 273, 278, 279, 280, 283, 284, 287, 288, 290, 291, 292, 294, 295, 305, 306, 315, 317, 318, 319, 320, 321, 322, 323, 324, 330, 331, 332, 333, 334, 336, 337, 340, 342, 343, 346, 350, 353, 354, 355, 360, 361, 363, 364, 366, 367, 368, 370, 371, 373, 374, 376, 382, 383, 386, 389, 392, 394, 397, 401, 407, 411, 413, 414, 416, 417, 423, 424, 425, 426, 427, 428, 429, 432, 434, 437, 438, 440, 442, 444, 446, 449, 453, 454, 456, 458, 459, 462, 467, 469, 471, 472, 473, 475, 477, 480, 482, 483, 484, 485, 492, 493, 496, 498, 499, 502, 504, 506, 507, 509, 513, 515, 518, 519, 520, 521, 522, 523, 527, 528, 529, 530, 532, 533, 534, 535, 536, 537, 538, 539, 541, 542, 543, 544, 545, 549, 552, 556, 560, 561, 562, 563, 566, 570, 571, 573, 574, 575, 577, 581, 582, 585, 588, 591, 592, 593, 594, 595, 596, 598, 599, 601, 602, 603, 605, 607, 619, 623, 625, 626, 628, 629, 630, 631, 632, 635, 638, 639, 648, 649, 650, 651, 652, 654, 657, 663, 667, 668, 669, 670, 672, 675, 681, 683, 684, 692, 693, 694, 695, 697, 698, 700, 704, 705, 706, 707, 708, 710, 713, 716, 718, 719, 722, 724, 727, 728, 731, 733, 734, 735, 736, 737, 740, 741, 744, 747, 748, 749, 750, 751, 754, 757, 762, 764, 765, 767, 768, 770, 772, 773, 774, 775, 777, 778, 779, 780, 781, 783, 791, 793, 795, 799, 800, 801, 802, 803, 804, 806, 808, 816, 818, 822, 823, 824, 825, 826, 833, 836, 837, 838, 841, 846, 848, 851, 852, 856, 857, 864, 873, 875, 877, 885, 886, 887, 888, 889, 890, 893, 894, 896, 897, 899, 901, 902, 903, 905, 907, 909, 911, 914]
,[13, 16, 19, 27, 37, 47, 49, 60, 61, 65, 67, 70, 73, 83, 86, 125, 128, 140, 147, 153, 159, 162, 165, 168, 170, 185, 209, 228, 239, 245, 250, 269, 270, 275, 285, 300, 311, 314, 316, 329, 341, 348, 349, 362, 369, 375, 377, 378, 379, 384, 395, 398, 408, 433, 439, 452, 465, 466, 470, 487, 501, 503, 514, 540, 548, 554, 555, 564, 568, 572, 584, 590, 634, 653, 655, 658, 659, 661, 665, 666, 671, 674, 696, 699, 702, 721, 739, 742, 746, 753, 769, 784, 790, 794, 809, 813, 827, 828, 843, 853, 855, 858, 859, 860, 865, 867, 874, 908, 915, 916]
,[1, 21, 25, 26, 45, 51, 96, 97, 113, 116, 118, 164, 169, 174, 180, 212, 213, 216, 217, 220, 231, 255, 276, 286, 297, 298, 326, 335, 344, 381, 387, 405, 420, 421, 422, 430, 436, 451, 460, 463, 474, 476, 505, 511, 512, 579, 586, 621, 633, 636, 646, 680, 685, 687, 689, 701, 725, 743, 761, 766, 805, 807, 814, 834, 835, 863, 871, 872, 876, 879, 892, 910, 913]
]
```
 
%% Cell type:code id:d190bd89 tags:
 
``` python
titre = ['agency', 'anxiety','avoiding', 'depression','ext. control', 'fatigue', 'hyper vigilance',
'trauma','int. control', 'memory', 'problem focused', 'quality of life',
'sadness', 'self efficacy','sleep','social','stress']
dim = len(titre)
seuils = [ 0.38646466, 0.13056517 , 0.16311094 , 0.5522181 , 0.4068393 , 0.4961518,
-0.12576449, -0.16419357 , 0.34581536, -0.06974197, -0.25050393 , 0.17414908,
-0.09691429, 0.39290804, 0.37336868, -0.30328006 , 0.23517847]
print(len(seuils))
 
indices = []
for i in range(17):
indices.append([i])
print(H_users.shape)
radar = []
 
for k in range(len(g)):
rows = H_users[g[k]]
v = np.full(dim, 0.0)
for i in range(len(rows)):
#print(len(rows[i]))
for j in range(len(rows[i])):
 
if(rows[i][j] > seuils[j]):
v[j] = v[j] + 1 #rows[i][j]
if(rows[i][j] < seuils[j]):
v[j] = v[j] - 1#+ rows[i][j]
v = v / len(rows)
radar.append(v)
print(radar)
 
scaler = MinMaxScaler()
radar = scaler.fit_transform(np.array(radar))
```
 
%% Output
 
17
(917, 17)
[array([-0.37748344, -0.50331126, -0.36423841, -0.99337748, -0.39072848,
-0.64238411, 0.16556291, 0.33774834, -0.26490066, -0.99337748,
0.36423841, -0.53642384, 0.00662252, -0.41721854, -0.68874172,
0.52317881, -0.65562914]), array([-0.4954955 , -0.62162162, -0.53153153, -1. , -0.69369369,
-0.51351351, -0.2972973 , -0.36936937, -0.47747748, 1. ,
0.20720721, -0.58558559, 0.18918919, -0.58558559, -0.45945946,
-1. , -0.53153153]), array([-0.43859649, -0.68421053, -0.47368421, -1. , -0.52631579,
-0.61403509, -0.05263158, 0.29824561, -0.33333333, 1. ,
-0.98245614, -0.40350877, 0.05263158, -0.29824561, -0.57894737,
1. , -0.61403509]), array([-0.70843373, -0.56144578, -0.62891566, -1. , -0.68674699,
-0.83614458, 0.2 , 0.4 , -0.56626506, 1. ,
1. , -0.5686747 , 0.36385542, -0.68433735, -0.5373494 ,
1. , -0.58795181]), array([-0.72727273, -0.76363636, -0.72727273, 1. , -0.74545455,
-0.07272727, -0.19090909, -0.01818182, -1. , 0.63636364,
0.65454545, -0.78181818, -0.03636364, -0.72727273, -0.70909091,
0.43636364, -0.58181818]), array([-0.53424658, -0.67123288, -0.57534247, 1. , -0.23287671,
-0.08219178, -0.31506849, 0.06849315, 1. , 0.64383562,
0.56164384, -0.80821918, 0.08219178, -0.56164384, -0.83561644,
0.63013699, -0.67123288])]
 
%% Cell type:code id:34d43f1e tags:
 
``` python
print(classPsy.shape)
radar2 = []
for k in range(len(g)):
rows = classPsy[g[k]]
v = np.full(dim, 0.0)
for i in range(len(rows)):
for j in range(len(rows[i])):
if(rows[i][j] == 2):
v[j] = v[j] + 1 #rows[i][j]
if(rows[i][j] == 0):
v[j] = v[j] - 1#+ rows[i][j]
v = v / len(rows)
radar2.append(v)
print(radar2)
scaler = MinMaxScaler()
radar2 = scaler.fit_transform(np.array(radar2))
print(radar2)
```
 
%% Output
 
(917, 17)
[array([-0.28476821, 0.01986755, 0. , 0.14569536, -0.23178808,
0.2384106 , 0.01324503, 0.07284768, -0.2384106 , -0.30463576,
0. , -0.06622517, -0.02649007, -0.15231788, -0.02649007,
0. , 0.04635762]), array([-0.24324324, 0.07207207, 0. , 0.04504505, -0.0990991 ,
0.25225225, 0.02702703, 0.05405405, -0.23423423, -0.02702703,
0. , -0.11711712, 0.10810811, -0.17117117, 0. ,
0. , 0.18018018]), array([-0.31578947, 0. , 0. , 0.07017544, -0.24561404,
0.1754386 , -0.03508772, 0.07017544, -0.22807018, -0.03508772,
0. , -0.12280702, 0.01754386, -0.28070175, -0.15789474,
0. , 0.10526316]), array([-0.22650602, -0.01686747, 0. , 0.1060241 , -0.14698795,
0.15421687, -0.02650602, -0.01445783, -0.18795181, -0.01445783,
0. , -0.09156627, 0.00240964, -0.1060241 , -0.21204819,
0. , 0.04096386]), array([-0.12727273, 0.00909091, 0. , 0.78181818, -0.13636364,
0.47272727, 0. , 0.00909091, -0.10909091, -0.04545455,
0. , -0.04545455, 0.00909091, -0.00909091, -0.05454545,
0. , 0.00909091]), array([-0.26027397, -0.04109589, 0. , 0.80821918, -0.19178082,
0.32876712, 0. , -0.01369863, -0.26027397, -0.12328767,
0. , -0.02739726, -0.05479452, -0.01369863, -0.05479452,
0. , -0.01369863])]
[[0.16455441 0.53869875 0. 0.13188382 0.0943655 0.26433588
0.77812042 1. 0.14461525 0. 0. 0.59304052
0.17375075 0.4726758 0.87507526 0. 0.30976178]
[0.38482645 1. 0. 0. 1. 0.30779335
1. 0.78473721 0.17223979 0.95668452 0. 0.05963646
1. 0.40326292 1. 0. 1. ]
[0. 0.36314068 0. 0.03292878 0. 0.06662806
0. 0.96939204 0.21301194 0.92890608 0. 0.
0.44405901 0. 0.25538278 0. 0.61358839]
[0.47361018 0.21409258 0. 0.07990188 0.67314696 0.
0.13815874 0. 0.47837478 1. 0. 0.32743771
0.35115553 0.64311739 0. 0. 0.28194152]
[1. 0.4434718 0. 0.96540633 0.74566049 1.
0.5648855 0.26972799 1. 0.89318032 0. 0.81073964
0.39216942 1. 0.7427686 0. 0.11754528]
[0.29448578 0. 0. 1. 0.36742475 0.54802058
0.5648855 0.00869591 0. 0.6249548 0. 1.
0. 0.98303558 0.74159402 0. 0. ]]
 
%% Cell type:code id:acb7d4df tags:
 
``` python
name_cluster=['Trauma', 'Sadness, stress and memory','Trauma and memory','Memory','Depression and associated symptoms', 'Depression']
categories = ['processing cost','mechanical properties','chemical stability',
'thermal stability', 'device integration']
titleGraph = []
for i in range(len(d)):
#titleGraph.append('DTCluster ' + str(i))
titleGraph.append('DTCluster: ' + name_cluster[i])
def radar_fig(i):
fig = go.Figure()
 
fig.add_trace(go.Scatterpolar(
r=radar[i],
theta=titre,
fill='toself',
name='H'
))
fig.add_trace(go.Scatterpolar(
r=radar2[i],
theta=titre,
fill='toself',
name='Class psy'
#text = 'r'
))
 
fig.update_layout(
polar=dict(
radialaxis=dict(
visible=True
#range=[0, 5]
)),
showlegend=False
)
fig.update_layout(title_text = titleGraph[i])
fig.update_layout(
font=dict(
#family="Courier New, monospace",
size=18, # Set the font size here
#color="RebeccaPurple"
)
)
 
 
fig.show()
fig.write_image(path+"radar"+str(i)+"_fig.png")
 
for i in range(len(d)):
radar_fig(i)
```
 
%% Output
 
 
 
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[17], line 47
44 fig.write_image(path+"radar"+str(i)+"_fig.png")
46 for i in range(len(d)):
---> 47 radar_fig(i)
Cell In[17], line 44, in radar_fig(i)
34 fig.update_layout(
35 font=dict(
36 #family="Courier New, monospace",
(...)
39 )
40 )
43 fig.show()
---> 44 fig.write_image(path+"radar"+str(i)+"_fig.png")
File ~/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/plotly/basedatatypes.py:3829, in BaseFigure.write_image(self, *args, **kwargs)
3769 """
3770 Convert a figure to a static image and write it to a file or writeable
3771 object
(...)
3825 None
3826 """
3827 import plotly.io as pio
-> 3829 return pio.write_image(self, *args, **kwargs)
File ~/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/plotly/io/_kaleido.py:267, in write_image(fig, file, format, scale, width, height, validate, engine)
251 raise ValueError(
252 """
253 Cannot infer image type from output path '{file}'.
(...)
261 )
262 )
264 # Request image
265 # -------------
266 # Do this first so we don't create a file if image conversion fails
--> 267 img_data = to_image(
268 fig,
269 format=format,
270 scale=scale,
271 width=width,
272 height=height,
273 validate=validate,
274 engine=engine,
275 )
277 # Open file
278 # ---------
279 if path is None:
280 # We previously failed to make sense of `file` as a pathlib object.
281 # Attempt to write to `file` as an open file descriptor.
File ~/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/plotly/io/_kaleido.py:133, in to_image(fig, format, width, height, scale, validate, engine)
131 # Raise informative error message if Kaleido is not installed
132 if scope is None:
--> 133 raise ValueError(
134 """
135 Image export using the "kaleido" engine requires the kaleido package,
136 which can be installed using pip:
137 $ pip install -U kaleido
138 """
139 )
141 # Validate figure
142 # ---------------
143 fig_dict = validate_coerce_fig_to_dict(fig, validate)
ValueError:
Image export using the "kaleido" engine requires the kaleido package,
which can be installed using pip:
$ pip install -U kaleido
 
%% Cell type:code id:c03ac5f8 tags:
 
``` python
```
 
%% Cell type:code id:39b0792d tags:
 
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment