Showing
1 changed file
with
25 additions
and
5 deletions
... | @@ -16,12 +16,14 @@ public class PostprocessingExpert { | ... | @@ -16,12 +16,14 @@ public class PostprocessingExpert { |
16 | Set<Long> sampleItemIds; | 16 | Set<Long> sampleItemIds; |
17 | Set<Long> recommendedItemIds; | 17 | Set<Long> recommendedItemIds; |
18 | Set<Long> sampleUserIds; | 18 | Set<Long> sampleUserIds; |
19 | + Set<Long> annotatedUserIds; | ||
19 | Map<Long, Set<Long>> sampleItemUserIds; | 20 | Map<Long, Set<Long>> sampleItemUserIds; |
20 | Map<Long, Integer> itemRecommandationUserCounts; | 21 | Map<Long, Integer> itemRecommandationUserCounts; |
21 | int recommendableItemCount; | 22 | int recommendableItemCount; |
22 | int recommendedItemCount; | 23 | int recommendedItemCount; |
23 | int recommendableItemUserCount; | 24 | int recommendableItemUserCount; |
24 | int annotatedItemUserCount; | 25 | int annotatedItemUserCount; |
26 | + int recommendedItemAnnotatedUserCount; | ||
25 | int recommendedItemUserCount; | 27 | int recommendedItemUserCount; |
26 | int validRecommendationCount; | 28 | int validRecommendationCount; |
27 | double itemRecommandationUserCountRelativeStdDeviation; | 29 | double itemRecommandationUserCountRelativeStdDeviation; |
... | @@ -36,6 +38,7 @@ public class PostprocessingExpert { | ... | @@ -36,6 +38,7 @@ public class PostprocessingExpert { |
36 | 38 | ||
37 | public void analyze() { | 39 | public void analyze() { |
38 | analyzeSample(); | 40 | analyzeSample(); |
41 | + analyzeAnnotated(); | ||
39 | analyzeRecommendations(); | 42 | analyzeRecommendations(); |
40 | } | 43 | } |
41 | 44 | ||
... | @@ -51,6 +54,19 @@ public class PostprocessingExpert { | ... | @@ -51,6 +54,19 @@ public class PostprocessingExpert { |
51 | return computePrecisionRecall(); | 54 | return computePrecisionRecall(); |
52 | } | 55 | } |
53 | 56 | ||
57 | + protected void analyzeAnnotated() { | ||
58 | + | ||
59 | + annotatedUserIds = new HashSet<>(); | ||
60 | + | ||
61 | + for (PostprocessingSample sample : annotatedList) { | ||
62 | + Long userId = sample.getUserId(); | ||
63 | + annotatedUserIds.add(userId); | ||
64 | + } | ||
65 | + | ||
66 | + annotatedItemUserCount = annotatedList.size(); | ||
67 | + logger.debug("PR: Nombre d'associations annotées {}", annotatedItemUserCount); | ||
68 | + } | ||
69 | + | ||
54 | protected void analyzeSample() { | 70 | protected void analyzeSample() { |
55 | 71 | ||
56 | sampleItemIds = new HashSet<>(); | 72 | sampleItemIds = new HashSet<>(); |
... | @@ -90,8 +106,10 @@ public class PostprocessingExpert { | ... | @@ -90,8 +106,10 @@ public class PostprocessingExpert { |
90 | protected void analyzeRecommendations() { | 106 | protected void analyzeRecommendations() { |
91 | recommendedItemUserCount = 0; | 107 | recommendedItemUserCount = 0; |
92 | validRecommendationCount = 0; | 108 | validRecommendationCount = 0; |
109 | + recommendedItemAnnotatedUserCount = 0; | ||
93 | recommendedItemIds = new HashSet<>(); | 110 | recommendedItemIds = new HashSet<>(); |
94 | itemRecommandationUserCounts = new HashMap<>(); | 111 | itemRecommandationUserCounts = new HashMap<>(); |
112 | + | ||
95 | for (PostprocessingSample annote : annotatedList) { | 113 | for (PostprocessingSample annote : annotatedList) { |
96 | logger.trace("Annotated item {}, user {}", annote.getItemId(), annote.getUserId()); | 114 | logger.trace("Annotated item {}, user {}", annote.getItemId(), annote.getUserId()); |
97 | } | 115 | } |
... | @@ -114,16 +132,18 @@ public class PostprocessingExpert { | ... | @@ -114,16 +132,18 @@ public class PostprocessingExpert { |
114 | } | 132 | } |
115 | } | 133 | } |
116 | logger.trace("Recommendation item {}, user {}", reco.getItemId(), reco.getUserId()); | 134 | logger.trace("Recommendation item {}, user {}", reco.getItemId(), reco.getUserId()); |
135 | + if (annotatedUserIds.contains(userId)) { | ||
136 | + recommendedItemAnnotatedUserCount++; | ||
137 | + } | ||
117 | if (annotatedList.contains(reco)) { | 138 | if (annotatedList.contains(reco)) { |
118 | validRecommendationCount++; | 139 | validRecommendationCount++; |
119 | } | 140 | } |
120 | } | 141 | } |
121 | recommendedItemCount = recommendedItemIds.size(); | 142 | recommendedItemCount = recommendedItemIds.size(); |
122 | logger.debug("C: Nombre d'objets recommandés {}", recommendedItemCount); | 143 | logger.debug("C: Nombre d'objets recommandés {}", recommendedItemCount); |
123 | - logger.debug("C/PR: Nombre de couples item-user recommandés {}", recommendedItemUserCount); | 144 | + logger.debug("C: Nombre de couples item-user recommandés {}", recommendedItemUserCount); |
124 | - annotatedItemUserCount = annotatedList.size(); | ||
125 | - logger.debug("PR: Nombre d'associations annotées {}", annotatedItemUserCount); | ||
126 | logger.debug("PR: Nombre de recommandations annotées {}", validRecommendationCount); | 145 | logger.debug("PR: Nombre de recommandations annotées {}", validRecommendationCount); |
146 | + logger.debug("PR: Nombre de couples item-user recommandés pour les users annotés {}", recommendedItemAnnotatedUserCount); | ||
127 | } | 147 | } |
128 | 148 | ||
129 | protected PostprocessingStatistics computeStatistics() { | 149 | protected PostprocessingStatistics computeStatistics() { |
... | @@ -169,8 +189,8 @@ public class PostprocessingExpert { | ... | @@ -169,8 +189,8 @@ public class PostprocessingExpert { |
169 | float recall; | 189 | float recall; |
170 | 190 | ||
171 | logger.debug("PR: nombre de recommandations annotées {}", validRecommendationCount); | 191 | logger.debug("PR: nombre de recommandations annotées {}", validRecommendationCount); |
172 | - logger.debug("PR: nombre de recommandations {}", recommendedItemUserCount); | 192 | + logger.debug("PR: nombre de recommandations pour utilisateurs annotés {}", recommendedItemAnnotatedUserCount); |
173 | - precision = (float) validRecommendationCount / recommendedItemUserCount; | 193 | + precision = (float) validRecommendationCount / recommendedItemAnnotatedUserCount; |
174 | logger.debug("PR: précision {}", String.format(Locale.FRENCH, "%.3f", precision)); | 194 | logger.debug("PR: précision {}", String.format(Locale.FRENCH, "%.3f", precision)); |
175 | logger.debug("PR: nombre d'associations annotées {}", annotatedItemUserCount); | 195 | logger.debug("PR: nombre d'associations annotées {}", annotatedItemUserCount); |
176 | recall = (float) validRecommendationCount / annotatedItemUserCount; | 196 | recall = (float) validRecommendationCount / annotatedItemUserCount; | ... | ... |
-
Please register or login to post a comment