Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
public-projects
intrec
Commits
b07e4579
Commit
b07e4579
authored
May 05, 2020
by
Alberto Monge
Browse files
intrec with simulated navigation-by-preference
parent
a6ea26cb
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
data/recommendations/eval@10
View file @
b07e4579
HIT@N
HIT@10-1 HIT@10-2 HIT@10-3 HIT@10-4 HIT@10-5
0,2147 0,3190 0,3865 0,4110 0,4847
SIM@10-1 SIM@10-2 SIM@10-3 SIM@10-4 SIM@10-5
0,6339 0,6523 0,6592 0,6610 0,6672
0,2147
\ No newline at end of file
data/recommendations/eval@3
View file @
b07e4579
HIT@N
HIT@3-1 HIT@3-2 HIT@3-3 HIT@3-4 HIT@3-5
0,1411 0,1595 0,2086 0,2331 0,2761
SIM@3-1 SIM@3-2 SIM@3-3 SIM@3-4 SIM@3-5
0,6493 0,6616 0,6636 0,6616 0,6697
0,1411
\ No newline at end of file
data/recommendations/eval@5
View file @
b07e4579
HIT@N
HIT@5-1 HIT@5-2 HIT@5-3 HIT@5-4 HIT@5-5
0,1534 0,2209 0,2761 0,3190 0,3620
SIM@5-1 SIM@5-2 SIM@5-3 SIM@5-4 SIM@5-5
0,6484 0,6622 0,6622 0,6867 0,6904
0,1534
\ No newline at end of file
data/recommendations/rec@10
View file @
b07e4579
This diff is collapsed.
Click to expand it.
data/recommendations/rec@3
View file @
b07e4579
4 678;408;905
5 2311;1037;3855
6 3340;1549;270
8 1031;1801;1546
9 2050;2051;2052
10 3584;3585;1027
11 1880;4284
12 3252;2677;1590
13 2050;2051;2052
14 1152;2688;3715
15 2311;1037;3855
17 833;1570;1091
18 2050;2051;2052
19 2673;2867;310
20 2087;298;413
21 2563;3347;779
23 2368;1602;1028
24 2368;1602;210
26 4072
27 1200;2429;3423
28 512;3584;3585
29 2050;2051;2052
30 3340;1549;270
31 2050;2051;2052
32 3584;3585;1027
33 4166;1739
34 1;1793;1031
35 210;1028;468
36 512;3584;3585
37 4033;4034;4037
38 2305;3329;2562
40 2050;2051;2052
41 2368;1602;1028
42 2563;3347;779
43 3340;1549;270
44 3340;1549;1805
45 4060
47 2050;2051;2052
49 3857;1805;2831
50 1;1793;1031
51 3340;1549;2062
52 2050;2051;2052
53 2305;3329;2562
54 768;1029;1036
55 2050;2051;2052
56 3340;1549;270
58 2311;1037;3855
59 512;3584;3585
60 3534
61 515;2308;714
62 4033;4034;4037
63 274;3858;799
64 2050;2051;2052
65 1321;4074;4076
66 1472;417;897
69 3857;1805;2831
70 2949;4277;2649
71 274;3858;799
72 3340;1549;1805
73 3340;1549;1805
74 2688;3715;774
75 2050;2051;2052
76 274;3858;799
77 2563;3347;779
79 3586;2435;1285
80 2050;2051;2052
81 2050;2051;2052
82 512;3584;3585
83 768;1025;1029
84 2368;1602;1028
85 1409;1733;3213
86 3857;1805;2831
88 3584;3585;1027
89 4080;1165
90 2465;4145;4018
91 2305;3329;2562
92 3713;3717;3721
93 1;1793;1031
94 2087;298;413
95 3776;4032;4151
97 2050;2051;2052
98 2050;2051;2052
99 2087;298;413
100 3586;2435;3592
101 3584;3585;1027
102 2050;2051;2052
103 2305;3329;2562
104 678;408;905
105 2311;3352;1037
107 2050;2051;2052
108 577;2115;591
109 1152;2688;3715
110 2050;2051;2052
111 274;3858;40
112 3584;3585;1027
113 274;3858;799
114 3201;1927;1308
115 1152;2688;3715
116 2311;1037;3855
118 2050;2051;2052
120 2050;2051;2052
123 3584;3585;1027
124 2050;2051;2052
125 274;3858;799
126 2050;2051;2052
127 274;3858;799
129 3584;3585;1027
130 2050;2051;2052
131 2050;2051;2052
132 2050;2051;2052
133 2050;2051;2052
135 2050;2051;1033
136 2050;2051;2054
137 3586;2435;1285
138 274;3858;799
139 2465;4018;1270
141 281;4047;4191
143 3857;1805;2831
144 3857;1805;2831
145 3857;1805;2831
146 4033;4034;4037
151 274;3858;799
152 115;1862;2635
154 1538;967;3017
155 274;3858;799
156 3857;1805;2831
157 1;1793;1031
158 3925;3319;2681
159 2128;501;1366
161 3291
162 3340;1549;1805
163 2305;3329;2562
164 2368;1602;1028
166 161;1706;3499
167 2050;2051;2052
168 3393;259;3204
170 1635;3236
171 2311;1037;3855
172 2052;2053;2054
174 512;3584;3585
175 2087;298;413
176 2050;2051;2052
177 2305;3329;2562
178 3340;1549;1805
179 2050;2051;2052
180 1;1793;1031
181 3776;4151;4186
182 2050;2051;2052
183 3340;1549;270
184 1549;270;2062
185 3857;1805;2831
186 3312;4276;2950
187 512;3584;3585
188 3520;3505;1655
189 2368;1602;1028
190 3340;1549;2062
192 2050;2051;2052
193 2050;2051;2052
194 3877;3879;1343
195 513;385;2611
196 2563;3347;779
197 2050;2051;2052
198 3340;1549;270
4 678;408;905
-4033;4155;4156-4034;4037;4038-4039;4040;4041-3157;4042;4043
5 2311;1037;3855
-3856;2081;3352-2343;2344;2090-819;2886;2888-346;2395;3931
6 3340;1549;270
-785;2062;2063-277;2073;2075-288;1571;808-301;1837;559
8 1031;1801;1546
-276;2327;11-1049;3869;1055-1824;2084;38-2855;299;1582
9 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
10 3584;3585;1027
-3588;3589;3590-2055;3591;3593-2576;530;2578-2580;534;26
11 1880;4284
-1880;4284-1880;4284-1880;4284-1880;4284
12 3252;2677;1590
-3252;2677;1590-3252;2677;1590-3252;2677;1590-3252;2677;1590
13 2050;2051;2052
-2054;1033;1034-2068;3092;2069-2074;3101;30-2078;3102;3103
14 1152;2688;3715
-774;2439;2184-2313;3722;268-1298;1422;1039-3986;3860;3223
15 2311;1037;3855
-3856;3352;2588-3357;2590;3358-2081;2593;3359-1061;2343;2344
17 833;1570;1091
-1284;2404;1317-1573;3205;1607-1461;2858;1581-3193;1018;3834
18 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
19 2673;2867;310
-3159;908;1774-2123;3788;2127-2123;3788;2127-2123;3788;2127
20 2087;298;413
-3780;3783;831-3785;4169;4170-3787;4171;4172-3156;3160;988
21 2563;3347;779
-533;1557;2326-322;3901;3902-582;3910;3911-2896;1617;1619
23 2368;1602;1028
-981;3609;1755-2976;287;687-2976;287;687-2976;287;687
24 2368;1602;210
-468;981;3609-2976;1755;287-2802;3065;687-2056;379;511
26 4072
-4072-4072-4072-4072
27 1200;2429;3423
-1200;2429;3423-1200;2429;3423-1200;2429;3423-1200;2429;3423
28 512;3584;3585
-1027;3588;3589-3590;2055;3591-2576;530;3593-2578;2580;534
29 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
30 3340;1549;270
-785;2062;2063-277;2073;2075-288;1571;808-301;1837;559
31 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
32 3584;3585;1027
-3588;3589;3590-2055;3591;3593-2576;530;2578-2580;534;26
33 4166;1739
-4166;1739-4166;1739-4166;1739-4166;1739
34 1;1793;1031
-1801;1546;11-272;17;276-2327;1049;29-1824;3869;1055
35 210;1028;468
-981;3609;1755-2976;287;687-2802;3065;379-1057;2056;1231
36 512;3584;3585
-1027;3588;3589-3590;2055;3591-2576;530;3593-2578;2580;534
37 4033;4034;4037
-4033;4034;4037-4033;4034;4037-4033;4034;4037-4033;4034;4037
38 2305;3329;2562
-772;3332;518-1543;520;1291-528;3601;2316-1046;3608;1305
40 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
41 2368;1602;1028
-210;468;981-3609;1755;287-3609;1755;287-3609;1755;287
42 2563;3347;779
-533;1557;2326-322;3901;3902-322;3901;3902-322;3901;3902
43 3340;1549;270
-785;2062;2063-277;2073;2075-1571;808;1837-3632;559;1839
44 3340;1549;1805
-785;2062;2063-1571;2073;2075-808;301;1837-3632;559;1839
45 4060
-4060-4060-4060-4060
47 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
49 3857;1805;2831
-3346;539;3100-1574;2335;1327-2880;1842;3385-1618;1092;2372
50 1;1793;1031
-1801;1546;11-272;17;276-2327;1049;29-1824;3869;1055
51 3340;1549;2062
-785;277;2063-288;2073;2075-1571;808;301-1837;559;1839
52 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
53 2305;3329;2562
-772;3332;518-1543;520;1291-528;3601;2316-1046;3608;1305
54 768;1029;1036
-1813;3341;527-1827;3350;1576-1857;809;2875-1860;2884;3141
55 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
56 3340;1549;270
-785;2062;2063-288;277;2073-1571;808;301-1837;559;1839
58 2311;1037;3855
-3856;3352;2588-3357;2590;3358-2081;2593;3359-2343;2344;2090
59 512;3584;3585
-1027;3588;3589-3590;2055;3591-2576;530;3593-2578;2580;534
60 3534
-3534-3534-3534-3534
61 515;2308;714
-1363;463;3471-1047;1432;3097-1626;1627;3039-2721;2530;1124
62 4033;4034;4037
-4038;4039;4040-905;4041;4042-3157;408;4043-678;1787;143
63 274;3858;799
-1840;40;552-52;820;2878-2624;1354;1099-2656;3409;2637
64 2050;2051;2052
-2053;2054;1034-2068;2069;2060-2074;3101;2078-3104;3102;3103
65 1321;4074;4076
-4178;4077;4078-4064;4179;282-4066;359;583-4081;4068;4069
66 1472;417;897
-2497;1251;647-1447;680;2538-13;238;911-242;54;55
69 3857;1805;2831
-3346;539;3100-1574;2335;1327-2880;1842;3385-1618;1092;2372
70 2949;4277;2649
-2949;4277;2649-2949;4277;2649-2949;4277;2649-2949;4277;2649
71 274;3858;799
-1840;40;552-52;820;2878-2624;1354;1099-2656;3409;2637
72 3340;1549;1805
-785;2062;2063-288;2073;2075-1571;1837;559-3632;3633;1839
73 3340;1549;1805
-785;2062;2063-288;2073;2075-288;2073;2075-288;2073;2075
74 2688;3715;774
-2439;2184;2313-3722;268;1422-1298;3986;1039-3860;3223;3612
75 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
76 274;3858;799
-1840;40;552-52;820;2878-2624;1354;1099-2656;3409;2637
77 2563;3347;779
-533;1557;2326-322;3901;3902-582;3910;3911-2896;1617;1619
79 3586;2435;1285
-3592;3723;3724-1296;3725;3727-3728;3729;1810-2834;3730;3731
80 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
81 2050;2051;2052
-2053;2054;1033-2068;3092;1034-2069;2074;3101-2078;3102;3103
82 512;3584;3585
-1027;3588;3589-3590;2055;3591-2576;530;3593-2578;2580;534
83 768;1025;1029
-1036;3341;527-1827;1813;3350-1576;809;2875-1857;1860;2884
84 2368;1602;1028
-210;468;981-3609;1755;287-2976;2802;687-3065;379;511
85 1409;1733;3213
-3344;3098;2139-3099;1436;1822-100;2474;684-753;694;2156
86 3857;1805;2831
-3346;539;3100-1574;2335;1327-2880;1842;3385-1618;1092;2372
88 3584;3585;1027
-3588;3589;3590-2055;3591;3593-2576;530;2578-2580;534;26
89 4080;1165
-4080;1165-4080;1165-4080;1165-4080;1165
90 2465;4145;4018
-2465;4145;4018-2465;4145;4018-2465;4145;4018-2465;4145;4018
91 2305;3329;2562
-772;3332;518-1543;1291;2316-3601;1046;3608-1305;794;1054
92 3713;3717;3721
-405;3541;3981-867;2393;3933-3941;3943;1128-3699;3704;1194
93 1;1793;1031
-1801;1546;11-272;17;276-2327;1049;29-2327;1049;29
94 2087;298;413
-3780;3783;831-3156;3785;3787-1504;3160;988-368;129;248
95 3776;4032;4151
-4186;2846;4030-4186;2846;4030-4186;2846;4030-4186;2846;4030
97 2050;2051;2052
-2054;1033;1034-2068;3092;2069-2074;3101;30-2078;3102;3103
98 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
99 2087;298;413
-3780;3783;831-3785;4170;3787-3785;4170;3787-3785;4170;3787
100 3586;2435;3592
-3723;3724;3725-1296;3728;3727-3729;1810;2834-3730;3731;3220
101 3584;3585;1027
-3588;3589;3590-2055;3591;3593-2576;530;2578-2580;534;26
102 2050;2051;2052
-2053;2054;1033-2068;3092;1034-2069;2074;3101-30;2078;3102
103 2305;3329;2562
-772;3332;518-1543;520;1291-528;3601;2316-1046;3608;1305
104 678;408;905
-4033;4155;4156-4034;4037;4038-4039;4040;4041-4039;4040;4041
105 2311;3352;1037
-2311;3352;1037-2311;3352;1037-2311;3352;1037-2311;3352;1037
107 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
108 577;2115;591
-977;1303;602-160;2788;1629-421;3496;236-421;3496;236
109 1152;2688;3715
-774;2439;2184-2313;3722;268-1298;1422;1039-3986;3860;1179
110 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
111 274;3858;40
-1840;52;552-2624;820;2878-3409;1354;2637-2656;871;1896
112 3584;3585;1027
-3588;3589;3590-2055;3591;3593-2576;530;2578-2580;534;26
113 274;3858;799
-1840;40;552-52;820;2878-2624;1354;1099-2656;3409;2637
114 3201;1927;1308
-1184;2466;2468-2214;2470;1710-1330;307;3631-3251;1460;2612
115 1152;2688;3715
-774;2439;2184-2313;3722;268-1298;1422;1039-3986;3860;3223
116 2311;1037;3855
-3856;3352;2588-3357;2590;3358-2081;2593;3359-1061;2343;2344
118 2050;2051;2052
-2053;1033;1034-2068;3092;2060-2069;2074;3101-30;2078;3102
120 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
123 3584;3585;1027
-3588;3589;3590-2055;3591;3593-2576;530;2578-2580;534;26
124 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
125 274;3858;799
-1840;40;552-52;820;2878-2624;1354;1099-2656;3409;2637
126 2050;2051;2052
-2053;2054;1034-2068;3092;2060-2069;2074;3101-30;2078;3102
127 274;3858;799
-1840;40;552-52;820;2878-2624;1354;1099-2656;3409;2637
129 3584;3585;1027
-3588;3589;3590-2055;3591;3593-2576;530;2578-2580;534;26
130 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
131 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
132 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
133 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
135 2050;2051;1033
-2068;1034;2060-3092;2069;2074-3101;30;2078-3104;3102;3103
136 2050;2051;2054
-1033;1034;2060-2068;3092;2069-2074;3101;30-2078;3102;3103
137 3586;2435;1285
-3592;3723;3724-1296;3725;3727-3728;3729;1810-2834;3730;3731
138 274;3858;799
-1840;40;552-52;820;2878-2624;1354;1099-2656;3409;2637
139 2465;4018;1270
-2465;4018;1270-2465;4018;1270-2465;4018;1270-2465;4018;1270
141 281;4047;4191
-281;4047;4191-281;4047;4191-281;4047;4191-281;4047;4191
143 3857;1805;2831
-3346;539;3100-1574;2335;1327-2880;1842;3385-1618;1092;2372
144 3857;1805;2831
-3346;539;3100-1574;2335;1327-2880;1842;3385-1618;1092;2372
145 3857;1805;2831
-3346;539;3100-1574;2335;1327-2880;1842;3385-1618;1092;2372
146 4033;4034;4037
-4038;4039;4040-905;4041;4042-3157;408;4043-4196;4197;4187
151 274;3858;799
-1840;40;552-52;820;2878-2624;1354;1099-2656;3409;2637
152 115;1862;2635
-115;1862;2635-115;1862;2635-115;1862;2635-115;1862;2635
154 1538;967;3017
-2324;2198;2314-1377;2353;1510-2354;3784;2431-2354;3784;2431
155 274;3858;799
-1840;40;552-52;820;2878-2624;1354;1099-2656;3409;2637
156 3857;1805;2831
-3346;539;3100-1574;2335;1327-2880;1842;3385-1618;1092;2372
157 1;1793;1031
-1801;1546;11-272;17;276-1049;29;3869-1824;2084;1055
158 3925;3319;2681
-3925;3319;2681-3925;3319;2681-3925;3319;2681-3925;3319;2681
159 2128;501;1366
-2128;501;1366-2128;501;1366-2128;501;1366-2128;501;1366
161 3291
-3291-3291-3291-3291
162 3340;1549;1805
-785;2062;2063-288;2073;2075-1571;808;301-1837;559;1839
163 2305;3329;2562
-772;3332;518-1543;520;1291-3601;1046;2316-3608;1305;794
164 2368;1602;1028
-210;468;981-2976;3609;1755-2802;3065;687-2056;379;511
166 161;1706;3499
-161;1706;3499-161;1706;3499-161;1706;3499-161;1706;3499
167 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
168 3393;259;3204
-3909;969;3145-3275;269;3853-722;1173;3023-25;1373;3165
170 1635;3236
-1635;3236-1635;3236-1635;3236-1635;3236
171 2311;1037;3855
-3856;3352;2588-3357;2590;3358-2081;2593;3359-1061;2343;2344
172 2052;2053;2054
-2068;3092;2069-2074;3101;30-2078;3102;3103-3104;3105;1059
174 512;3584;3585
-1027;3588;3589-3590;2055;3591-2576;530;3593-2578;2580;534
175 2087;298;413
-3780;3783;831-3785;4169;4170-3787;4171;4172-3156;3160;988
176 2050;2051;2052
-2053;1033;1034-2068;3092;2060-2069;2074;3101-30;2078;3102
177 2305;3329;2562
-772;3332;518-1543;520;1291-528;3601;2316-1046;3608;1305
178 3340;1549;1805
-785;2062;2063-277;2073;2075-277;2073;2075-277;2073;2075
179 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
180 1;1793;1031
-1801;1546;11-272;17;276-2327;1049;29-1824;3869;1055
181 3776;4151;4186
-2846;4030-2846;4030-2846;4030-2846;4030
182 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
183 3340;1549;270
-785;2062;2063-277;2073;2075-288;1571;808-301;1837;559
184 1549;270;2062
-785;2073;2063-288;1571;2075-808;301;1837-3632;559;1839
185 3857;1805;2831
-3346;539;3100-1574;2335;1327-2880;1842;3385-1618;1092;2372
186 3312;4276;2950
-3312;4276;2950-3312;4276;2950-3312;4276;2950-3312;4276;2950
187 512;3584;3585
-512;3584;3585-512;3584;3585-512;3584;3585-512;3584;3585
188 3520;3505;1655
-1239;537;3978-1239;537;3978-1239;537;3978-1239;537;3978
189 2368;1602;1028
-210;468;981-3609;1755;287-3609;1755;287-3609;1755;287
190 3340;1549;2062
-785;2073;2063-288;1571;2075-808;301;1837-3632;559;1839
192 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
193 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
194 3877;3879;1343
-2904;2905;2906-2907;2908;2910-2417;2418;2911-2420;2421;2422
195 513;385;2611
-513;385;2611-513;385;2611-513;385;2611-513;385;2611
196 2563;3347;779
-533;1557;2326-582;3901;3902-2896;3910;3911-1617;1619;1364
197 2050;2051;2052
-2053;2054;1033-2068;1034;2060-3092;2069;2074-3101;30;2078
198 3340;1549;270
-785;2062;2063-288;2073;2075-1571;301;1837-3632;559;1839
data/recommendations/rec@5
View file @
b07e4579
This diff is collapsed.
Click to expand it.
src/main/java/it/polito/elite/intrec/App.java
View file @
b07e4579
...
...
@@ -26,7 +26,7 @@ public class App
//compute recommendations
intrec
.
computeRecommendations
(
items
,
classesIndex
,
trainingSet
,
testSet
,
features
,
intentions
);
//evaluate recommendations
intrec
.
evaluate
(
trainingSet
,
testSet
);
intrec
.
evaluate
(
trainingSet
,
testSet
,
features
);
}
catch
(
OWLOntologyCreationException
e
)
{
// TODO Auto-generated catch block
...
...
src/main/java/it/polito/elite/intrec/services/EvaluatorService.java
View file @
b07e4579
...
...
@@ -9,45 +9,89 @@ import org.slf4j.LoggerFactory;
public
class
EvaluatorService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
().
getName
());
private
InputService
inputService
;
private
OwlExtractorService
owlService
;
public
EvaluatorService
()
{
inputService
=
new
InputService
();
public
EvaluatorService
(
InputService
inputService
,
OwlExtractorService
owlService
)
{
this
.
inputService
=
inputService
;
this
.
owlService
=
owlService
;
}
public
void
evaluate
(
Map
<
Long
,
Set
<
Long
>>
recommendations
,
Map
<
Long
,
Map
<
Long
,
Float
>>
trainingSet
,
Map
<
Long
,
Map
<
Long
,
Float
>>
testSet
,
String
[]
evaluationMetrics
,
String
evaluationFile
,
int
topN
)
{
public
void
evaluate
(
Map
<
Long
,
Map
<
Integer
,
Set
<
Long
>>
>
recommendations
,
Map
<
Long
,
Map
<
Long
,
Float
>>
trainingSet
,
Map
<
Long
,
Map
<
Long
,
Float
>>
testSet
,
Map
<
Long
,
Set
<
Long
>>
features
,
String
[]
evaluationMetrics
,
String
evaluationFile
,
int
topN
,
int
cycles
)
{
String
evalOutputHeading
=
new
String
();
String
evalOutputContent
=
new
String
();
String
fileContent
=
new
String
();
for
(
String
evalMetric
:
evaluationMetrics
)
{
evalOutputHeading
+=
evalMetric
;
evalOutputHeading
+=
"\t"
;
}
for
(
String
evalMetric
:
evaluationMetrics
)
{
logger
.
info
(
String
.
format
(
"Evaluating %s for top %d recommendations"
,
evalMetric
,
topN
));
String
evalOutputHeading
=
new
String
();
String
evalOutputContent
=
new
String
();
switch
(
evalMetric
)
{
case
"HIT@N"
:
double
avgHIT
=
computeHIT
(
recommendations
,
trainingSet
,
testSet
);
logger
.
info
(
String
.
format
(
"HIT@%d\t%f"
,
topN
,
avgHIT
));
evalOutputContent
+=
String
.
format
(
"%.4f"
,
avgHIT
);
evalOutputContent
+=
"\t"
;
for
(
int
i
=
1
;
i
<=
cycles
;
i
++)
{
String
m
=
String
.
format
(
"HIT@%d-%d"
,
topN
,
i
);
evalOutputHeading
+=
String
.
format
(
"%10s"
,
m
);
double
avgHIT
=
computeHIT
(
recommendations
,
i
,
trainingSet
,
testSet
);
logger
.
info
(
String
.
format
(
"HIT@%d-%d\t%f"
,
topN
,
i
,
avgHIT
));
evalOutputContent
+=
String
.
format
(
"%10.4f"
,
avgHIT
);
}
fileContent
+=
evalOutputHeading
;
fileContent
+=
"\n"
;
fileContent
+=
evalOutputContent
;
fileContent
+=
"\n\n"
;
break
;
case
"SIM@N"
:
for
(
int
i
=
1
;
i
<=
cycles
;
i
++)
{
String
m
=
String
.
format
(
"SIM@%d-%d"
,
topN
,
i
);
evalOutputHeading
+=
String
.
format
(
"%10s"
,
m
);
double
avgSIM
=
computeSIM
(
recommendations
,
i
,
trainingSet
,
testSet
,
features
);
logger
.
info
(
String
.
format
(
"SIM@%d-%d\t%f"
,
topN
,
i
,
avgSIM
));
evalOutputContent
+=
String
.
format
(
"%10.4f"
,
avgSIM
);
}
fileContent
+=
evalOutputHeading
;
fileContent
+=
"\n"
;
fileContent
+=
evalOutputContent
;
fileContent
+=
"\n\n"
;
break
;
default
:
logger
.
info
(
String
.
format
(
"Metric %s not supported"
,
evalMetric
));
}
}
}
inputService
.
writeEvaluation
(
fileContent
,
evaluationFile
);
}
private
double
computeSIM
(
Map
<
Long
,
Map
<
Integer
,
Set
<
Long
>>>
recommendations
,
int
cycle
,
Map
<
Long
,
Map
<
Long
,
Float
>>
trainingSet
,
Map
<
Long
,
Map
<
Long
,
Float
>>
testSet
,
Map
<
Long
,
Set
<
Long
>>
features
)
{
double
avgSIM
=
0.0
;
for
(
Long
userId
:
recommendations
.
keySet
())
{
double
userAvgSIM
=
0.0
;
//get the target item
Long
target
=
testSet
.
get
(
userId
).
keySet
().
iterator
().
next
();
for
(
Long
rec
:
recommendations
.
get
(
userId
).
get
(
cycle
))
{
userAvgSIM
+=
this
.
owlService
.
computeSimilarity
(
features
.
get
(
rec
),
features
.
get
(
target
));
}
userAvgSIM
=
(
double
)
userAvgSIM
/
recommendations
.
get
(
userId
).
get
(
cycle
).
size
();
avgSIM
+=
userAvgSIM
;
}
inputService
.
writeEvaluation
(
evalOutputHeading
,
evalOutputContent
,
evaluationFile
);
return
(
double
)
avgSIM
/
(
double
)
recommendations
.
keySet
().
size
(
);
}
private
double
computeHIT
(
Map
<
Long
,
Set
<
Long
>>
recommendations
,
Map
<
Long
,
Map
<
Long
,
Float
>>
trainingSet
,
private
double
computeHIT
(
Map
<
Long
,
Map
<
Integer
,
Set
<
Long
>>
>
recommendations
,
int
cycle
,
Map
<
Long
,
Map
<
Long
,
Float
>>
trainingSet
,
Map
<
Long
,
Map
<
Long
,
Float
>>
testSet
)
{
double
avgHIT
=
0
;
double
avgHIT
=
0.
0
;
for
(
Long
userId
:
recommendations
.
keySet
())
{
for
(
Long
rec
:
recommendations
.
get
(
userId
))
{
for
(
Long
rec
:
recommendations
.
get
(
userId
)
.
get
(
cycle
)
)
{
if
(
testSet
.
get
(
userId
).
keySet
().
contains
(
rec
))
{
avgHIT
+=
1
;
break
;
...
...
src/main/java/it/polito/elite/intrec/services/InputService.java
View file @
b07e4579
...
...
@@ -5,6 +5,7 @@ import java.io.BufferedWriter;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.FileWriter
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -271,8 +272,8 @@ public class InputService {
* @param recommendationsFile the relative path of the file containing the recommendations
* @return a map storing recommendations for all the users
*/
public
Map
<
Long
,
Set
<
Long
>>
readRecommendations
(
String
recommendationsFile
){
Map
<
Long
,
Set
<
Long
>>
recommendations
=
new
ConcurrentHashMap
<>();
public
Map
<
Long
,
Map
<
Integer
,
Set
<
Long
>>
>
readRecommendations
(
String
recommendationsFile
){
Map
<
Long
,
Map
<
Integer
,
Set
<
Long
>>
>
recommendations
=
new
ConcurrentHashMap
<>();
try
{
BufferedReader
br
=
new
BufferedReader
(
new
FileReader
(
recommendationsFile
));
String
line
=
null
;
...
...
@@ -281,12 +282,18 @@ public class InputService {
String
[]
vals
=
line
.
split
(
"\t"
);
Long
userId
=
Long
.
parseLong
(
vals
[
0
]);
if
(!
recommendations
.
containsKey
(
userId
))
recommendations
.
put
(
userId
,
new
Hash
Set
<>());
recommendations
.
put
(
userId
,
new
Hash
Map
<>());
if
(
vals
.
length
>
1
)
{
String
[]
rules
=
vals
[
1
].
split
(
";"
);
for
(
String
rule
:
rules
)
{
recommendations
.
get
(
userId
).
add
(
Long
.
parseLong
(
rule
));
String
[]
cycles
=
vals
[
1
].
split
(
"-"
);
Integer
i
=
1
;
for
(
String
cycle
:
cycles
)
{
recommendations
.
get
(
userId
).
put
(
i
,
new
HashSet
<>());
String
[]
recs
=
cycle
.
split
(
";"
);
for
(
String
rec
:
recs
)
{
recommendations
.
get
(
userId
).
get
(
i
).
add
(
Long
.
parseLong
(
rec
));
}
i
++;
}
}
...
...
@@ -451,18 +458,25 @@ public class InputService {
* @param recommendations the computed recommendations
* @param recommendationsFile the relative path of the file to store recommendations
*/
public
void
writeRecommendations
(
Map
<
Long
,
Set
<
Long
>>
recommendations
,
String
recommendationsFile
)
{
public
void
writeRecommendations
(
Map
<
Long
,
Map
<
Integer
,
Set
<
Long
>>
>
recommendations
,
String
recommendationsFile
)
{
BufferedWriter
writer
;
try
{
writer
=
new
BufferedWriter
(
new
FileWriter
(
recommendationsFile
,
false
));
for
(
Long
userId
:
recommendations
.
keySet
())
{
String
line
=
userId
+
"\t"
;
for
(
Long
rec
:
recommendations
.
get
(
userId
))
{
line
+=
rec
;
line
+=
";"
;
}
for
(
Integer
cycle
:
recommendations
.
get
(
userId
).
keySet
())
{
for
(
Long
rec
:
recommendations
.
get
(
userId
).
get
(
cycle
))
{
line
+=
rec
;
line
+=
";"
;
}
line
=
line
.
substring
(
0
,
line
.
length
()-
1
);
line
+=
"-"
;
}
line
=
line
.
substring
(
0
,
line
.
length
()-
1
);
writer
.
append
(
line
);
...
...
@@ -482,18 +496,15 @@ public class InputService {
/**
* Write the result of an evaluation in a file
*
* @param evalOutputHeading the first line (heading) of the file
* @param evalOutputContent the content of the file
* @param evaluationFile the relative path of the file to store the evaluation results
* @param fileContent the content of the file
* @param the relative path of the file to store evaluation results
*/
public
void
writeEvaluation
(
String
evalOutputHeading
,
String
evalOutput
Content
,
String
evaluationFile
)
{
public
void
writeEvaluation
(
String
file
Content
,
String
evaluationFile
)
{
BufferedWriter
writer
;
try
{
writer
=
new
BufferedWriter
(
new
FileWriter
(
evaluationFile
,
false
));
writer
.
append
(
evalOutputHeading
);
writer
.
newLine
();
writer
.
newLine
();
writer
.
append
(
evalOutputContent
);
writer
.
append
(
fileContent
);
writer
.
flush
();
writer
.
close
();
...
...
src/main/java/it/polito/elite/intrec/services/IntrecService.java
View file @
b07e4579
...
...
@@ -2,6 +2,7 @@ package it.polito.elite.intrec.services;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
...
...
@@ -30,7 +31,6 @@ public class IntrecService {
private
OwlExtractorService
owlService
;
private
EvaluatorService
evaluator
;
//GENERAL SETTINGS
private
int
nThreads
;
private
String
baseAddress
;
...
...
@@ -47,6 +47,7 @@ public class IntrecService {
private
int
intentionsLevel
;
private
String
intentionsFile
;
//LEARNING
private
int
cycles
;
private
double
theta
;
private
double
eta
;
private
boolean
gif
;
...
...
@@ -66,7 +67,7 @@ public class IntrecService {
loadParams
(
props
);
inputService
=
new
InputService
();
owlService
=
new
OwlExtractorService
(
ontologyEndPoint
,
intentionsLevel
);
evaluator
=
new
EvaluatorService
();
evaluator
=
new
EvaluatorService
(
inputService
,
owlService
);