Toggle navigation
Toggle navigation
This project
Loading...
Sign in
grogv3
/
grog-cubi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Francois Leveque
2017-05-18 11:34:13 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3aa413f5f378da9e4a8ca49b057db8e31f7631ca
3aa413f5
1 parent
624e8624
Correction calcul précision et rappel
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
grog-recommendation/grog-recommendation-postprocess/src/main/java/org/legrog/recommendation/postprocess/PostprocessingExpert.java
grog-recommendation/grog-recommendation-postprocess/src/main/java/org/legrog/recommendation/postprocess/PostprocessingExpert.java
View file @
3aa413f
...
...
@@ -16,12 +16,14 @@ public class PostprocessingExpert {
Set
<
Long
>
sampleItemIds
;
Set
<
Long
>
recommendedItemIds
;
Set
<
Long
>
sampleUserIds
;
Set
<
Long
>
annotatedUserIds
;
Map
<
Long
,
Set
<
Long
>>
sampleItemUserIds
;
Map
<
Long
,
Integer
>
itemRecommandationUserCounts
;
int
recommendableItemCount
;
int
recommendedItemCount
;
int
recommendableItemUserCount
;
int
annotatedItemUserCount
;
int
recommendedItemAnnotatedUserCount
;
int
recommendedItemUserCount
;
int
validRecommendationCount
;
double
itemRecommandationUserCountRelativeStdDeviation
;
...
...
@@ -36,6 +38,7 @@ public class PostprocessingExpert {
public
void
analyze
()
{
analyzeSample
();
analyzeAnnotated
();
analyzeRecommendations
();
}
...
...
@@ -51,6 +54,19 @@ public class PostprocessingExpert {
return
computePrecisionRecall
();
}
protected
void
analyzeAnnotated
()
{
annotatedUserIds
=
new
HashSet
<>();
for
(
PostprocessingSample
sample
:
annotatedList
)
{
Long
userId
=
sample
.
getUserId
();
annotatedUserIds
.
add
(
userId
);
}
annotatedItemUserCount
=
annotatedList
.
size
();
logger
.
debug
(
"PR: Nombre d'associations annotées {}"
,
annotatedItemUserCount
);
}
protected
void
analyzeSample
()
{
sampleItemIds
=
new
HashSet
<>();
...
...
@@ -90,8 +106,10 @@ public class PostprocessingExpert {
protected
void
analyzeRecommendations
()
{
recommendedItemUserCount
=
0
;
validRecommendationCount
=
0
;
recommendedItemAnnotatedUserCount
=
0
;
recommendedItemIds
=
new
HashSet
<>();
itemRecommandationUserCounts
=
new
HashMap
<>();
for
(
PostprocessingSample
annote
:
annotatedList
)
{
logger
.
trace
(
"Annotated item {}, user {}"
,
annote
.
getItemId
(),
annote
.
getUserId
());
}
...
...
@@ -114,16 +132,18 @@ public class PostprocessingExpert {
}
}
logger
.
trace
(
"Recommendation item {}, user {}"
,
reco
.
getItemId
(),
reco
.
getUserId
());
if
(
annotatedUserIds
.
contains
(
userId
))
{
recommendedItemAnnotatedUserCount
++;
}
if
(
annotatedList
.
contains
(
reco
))
{
validRecommendationCount
++;
}
}
recommendedItemCount
=
recommendedItemIds
.
size
();
logger
.
debug
(
"C: Nombre d'objets recommandés {}"
,
recommendedItemCount
);
logger
.
debug
(
"C/PR: Nombre de couples item-user recommandés {}"
,
recommendedItemUserCount
);
annotatedItemUserCount
=
annotatedList
.
size
();
logger
.
debug
(
"PR: Nombre d'associations annotées {}"
,
annotatedItemUserCount
);
logger
.
debug
(
"C: Nombre de couples item-user recommandés {}"
,
recommendedItemUserCount
);
logger
.
debug
(
"PR: Nombre de recommandations annotées {}"
,
validRecommendationCount
);
logger
.
debug
(
"PR: Nombre de couples item-user recommandés pour les users annotés {}"
,
recommendedItemAnnotatedUserCount
);
}
protected
PostprocessingStatistics
computeStatistics
()
{
...
...
@@ -169,8 +189,8 @@ public class PostprocessingExpert {
float
recall
;
logger
.
debug
(
"PR: nombre de recommandations annotées {}"
,
validRecommendationCount
);
logger
.
debug
(
"PR: nombre de recommandations
{}"
,
recommendedItem
UserCount
);
precision
=
(
float
)
validRecommendationCount
/
recommendedItemUserCount
;
logger
.
debug
(
"PR: nombre de recommandations
pour utilisateurs annotés {}"
,
recommendedItemAnnotated
UserCount
);
precision
=
(
float
)
validRecommendationCount
/
recommendedItem
Annotated
UserCount
;
logger
.
debug
(
"PR: précision {}"
,
String
.
format
(
Locale
.
FRENCH
,
"%.3f"
,
precision
));
logger
.
debug
(
"PR: nombre d'associations annotées {}"
,
annotatedItemUserCount
);
recall
=
(
float
)
validRecommendationCount
/
annotatedItemUserCount
;
...
...
Please
register
or
login
to post a comment