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

emb name

parent d5e68713
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:c0bd6c14 tags:
``` python
path = "./"
datasets = ['assist09', 'assist17', 'algebra','math1', 'math2']
```
%% Cell type:markdown id:1da92e4f tags:
## Table 2: compute ACC, AUC and RMSE
%% Cell type:code id:61c53cb1 tags:
``` python
import os
print(os.getcwd())
cmd = 'cd code/binary_bpr && python ./script.py '
!{cmd}
```
%% Output
/home/arthurb/Programmation/cd-bpr
Is CUDA supported by this system? False
CUDA version: None
Is CUDA supported by this system? False
CUDA version: None
dataTrain: ../../data/cdbpr_format/assist0910_tkde/train_valid_0.csv
dataTest: ../../data/cdbpr_format/assist0910_tkde/test_0.csv
dataPath: ../../data/cdbpr_format/
embPath: ../../results/table_2/
epochs: 1
batch_size: 512
NB KC 123
NB Users 2493
NB Items 30338 30338
[Epoch 0] loss: 1.363575
[Epoch 0] loss: 1.372935
Best iteration 0
Accuracy train 0
save
save
../../results/table_2/users/assist0910_tkdeBPR_13-02-24__16h50min.csv
doa 0.7137409040368168
../../results/table_2/users/assist0910_tkde_0_BPR_.csv
doa 0.7099612984409824
Evaluate
RMSE 0.4479392060757274
AUC: 0.7225720124766046
RMSE 0.44733880081516414
AUC: 0.7248017059159078
0
Doa on Train dataset: 0.7137409040368168
AUC and RMSE on test dataset: 0.7225720124766046 0.4479392060757274
doa 0.4572501533642006
Accuracy and Doa on test dataset: 0.6944114882667447 0.4572501533642006
Doa on Train dataset: 0.7099612984409824
AUC and RMSE on test dataset: 0.7248017059159078 0.44733880081516414
doa 0.4637663632866919
Accuracy and Doa on test dataset: 0.696830557310365 0.4637663632866919
dataTrain: ../../data/cdbpr_format/assist0910_tkde/train_valid_1.csv
dataTest: ../../data/cdbpr_format/assist0910_tkde/test_1.csv
dataPath: ../../data/cdbpr_format/
embPath: ../../results/table_2/
epochs: 1
batch_size: 512
NB KC 123
NB Users 2493
NB Items 30338 30338
^C
Traceback (most recent call last):
File "/home/arthurb/Programmation/cd-bpr/code/binary_bpr/main.py", line 323, in <module>
File "/home/arthurb/Programmation/cd-bpr/code/binary_bpr/main.py", line 321, in <module>
dico_items, t_train, ty_train, item_users = parse_dataframe(dataTrain, dico_kc, dico_users, dico_items, True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/Programmation/cd-bpr/code/binary_bpr/main.py", line 114, in parse_dataframe
File "/home/arthurb/Programmation/cd-bpr/code/binary_bpr/main.py", line 112, in parse_dataframe
for row_index, row in df_group.iterrows():
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/frame.py", line 1450, in iterrows
s = klass(v, index=columns, name=k).__finalize__(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/series.py", line 521, in __init__
self.name = name
^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/generic.py", line 6225, in __setattr__
object.__setattr__(self, name, value)
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/series.py", line 703, in name
@name.setter
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/generic.py", line 6217, in __setattr__
object.__getattribute__(self, name)
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/series.py", line 701, in name
return self._name
^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/core/generic.py", line 6189, in __getattr__
@final
KeyboardInterrupt
%% Cell type:code id:d58e5e252cfd77e4 tags:
``` python
test = "/dgdfdf/duyt/eer"
test.split('/')[-2]
```
%% Output
'duyt'
%% Cell type:markdown id:6b1c6b4d tags:
## Table 3: compute DOA
%% Cell type:code id:790a43dd tags:
``` python
i = 3
'''
cmd = 'cd '+path+'binary_model/'
cmd = 'ls'
os.system(cmd)
print(os.getcwd())
os.system(cmd)
'''
embDirPath = "../../results/table_2/users/"
print(os.getcwd())
cmd = 'python ./binary_model/compute_doa.py --data '+path+'cv/data/'+datasets[i]+'/train'
cmd = 'python ./code/binary/compute_doa.py --data '+embDirPath+datasets[i]+'/train'
!{cmd}
#doa = compute_doa(path+datasets[i]+'/train_embed.csv')
#print("DOA:", doa)
```
%% Output
/home/arthurb/Téléchargements/code
Traceback (most recent call last):
File "/home/arthurb/Téléchargements/code/./binary_model/compute_doa.py", line 11, in <module>
doa = compute_doa(data)
^^^^^^^^^^^^^^^^^
File "/home/arthurb/Téléchargements/code/binary_model/utils.py", line 161, in compute_doa
F = fromDFtoArray(filename+"_embed.csv",False,'f')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/Téléchargements/code/binary_model/utils.py", line 7, in fromDFtoArray
df = pd.read_csv(name,index_col=None, header=None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/io/parsers/readers.py", line 948, in read_csv
return _read(filepath_or_buffer, kwds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/io/parsers/readers.py", line 611, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/io/parsers/readers.py", line 1448, in __init__
self._engine = self._make_engine(f, self.engine)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/io/parsers/readers.py", line 1705, in _make_engine
self.handles = get_handle(
^^^^^^^^^^^
File "/home/arthurb/anaconda3/envs/cdbpr-env/lib/python3.11/site-packages/pandas/io/common.py", line 863, in get_handle
handle = open(
^^^^^
FileNotFoundError: [Errno 2] No such file or directory: './cv/data/math1/train_embed.csv'
/home/arthurb/Programmation/cd-bpr
python: can't open file '/home/arthurb/Programmation/cd-bpr/./code/binary_model/compute_doa.py': [Errno 2] No such file or directory
%% Cell type:markdown id:8d5630b5 tags:
## Table 4: ablation --
%% Cell type:code id:a9e32954 tags:
``` python
# 0 no ablation, 1 ablation L2, 2 ablation init, 3 both
for abla in range(4):
for i in range(5):
cmd = 'python ./binary_model/main.py --dataTrain '+ path+'data/'+datasets[i]+'/train.csv --dataTest '+path+'data/'+datasets[i]+'/test.csv --ablation '+str(abla)
os.system(cmd)
```
%% Output
NB KC 16
NB Users 3911
NB (question-answer) in the data 20
Epoch 1, Loss: 1.3062841892242432
Epoch 11, Loss: 1.1247220039367676
DOA: 0.7652701270601657
RMSE 0.4360310956805937
AUC: 0.7970107606624546
ACC: 0.7257046201050292
Prec: 0.6802376862726893
NB KC 16
NB Users 3911
NB (question-answer) in the data 20
Epoch 1, Loss: 0.5947433114051819
Epoch 11, Loss: 0.5205552577972412
DOA: 0.5024588330075522
RMSE 0.42992933328684846
AUC: 0.804911997323218
ACC: 0.7328639144031627
Prec: 0.6869165325362152
NB KC 16
NB Users 3911
NB (question-answer) in the data 20
Epoch 1, Loss: 1.3599088191986084
Epoch 11, Loss: 1.124066948890686
DOA: 0.8408919219715537
RMSE 0.43537672319707393
AUC: 0.7967248771358717
ACC: 0.727651790806994
Prec: 0.6844450698939863
NB KC 16
NB Users 3911
NB (question-answer) in the data 20
Epoch 1, Loss: 0.694855809211731
Epoch 11, Loss: 0.5210095643997192
DOA: 0.501724768179482
RMSE 0.4295033431283873
AUC: 0.8059136173588548
ACC: 0.7314281218653502
Prec: 0.6849403122130395
%% Cell type:markdown id:c5960372 tags:
## Table 6 --
%% Cell type:code id:e46ff5d4 tags:
``` python
# pour all
cmd = 'python ./nary_model/main_nary_cv.py --data '+ path+'data/covid/initsurvey.csv'
print(os.system(cmd))
cmd = 'python ./nary_model/main_nary_cv.py --data '+path+'data/covid/psysurvey.csv'
print(os.system(cmd))
```
%% Output
avg values 0.8171224732461354 0.7558291282588128 0.7514963299272839 0.6211694246268313
0
avg values 0.8217752573238839 0.8345388354351844 0.8288387755136633 0.5900735950578464
0
%% Cell type:markdown id:e586f5cb tags:
## Figure 1 and Table 7
%% Cell type:code id:4c4b8106 tags:
``` python
cmd = 'python ./other/decision_tree.py --lower 0'
print(os.system(cmd))
cmd = 'python ./other/decision_tree.py --lower 1'
print(os.system(cmd))
```
%% Output
/home/celine/travail.svn/recherche/phd_subject/Arthur/code/other/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/celine/travail.svn/recherche/phd_subject/Arthur/code/other/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+ "other/dt/train_embed.csv",False,'f')
classPsy = fromDFtoArray(path+ "other/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
%% Cell type:code id:c03ac5f8 tags:
``` python
```
%% Cell type:code id:39b0792d tags:
``` python
```
......
File moved
File moved
File moved
File moved
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