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-24 12:29:54 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9a422b3c188a39f8e41441d19ddb3086f8996b40
9a422b3c
1 parent
d0623343
Ajout paramétrage seuil d'annotation
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
grog-recommendation/grog-recommendation-preprocess/src/main/java/org/legrog/recommendation/preprocess/PreprocessingRunner.java
grog-recommendation/grog-recommendation-preprocess/src/main/java/org/legrog/recommendation/preprocess/PreprocessingRunner.java
View file @
9a422b3
...
...
@@ -51,6 +51,7 @@ public class PreprocessingRunner implements ApplicationRunner {
private
Boolean
ratings
;
private
float
annotatePercent
;
private
int
annotateThreshold
;
@Override
public
void
run
(
ApplicationArguments
applicationArguments
)
throws
Exception
{
...
...
@@ -58,7 +59,7 @@ public class PreprocessingRunner implements ApplicationRunner {
setFilenames
();
List
<
AssociationElement
>
associationElements
=
loadAssociationElements
(
new
File
(
dataDir
,
completeFilename
));
// associationElements = cleanupSmallCounts(associationElements, 1, 1);
List
<
AssociationElement
>
annotableElements
=
removeFirstSmallCounts
(
associationElements
,
1
,
1
);
List
<
AssociationElement
>
annotableElements
=
removeFirstSmallCounts
(
associationElements
);
List
<
Integer
>
annotateIndexes
=
chooseAnnotated
(
associationElements
,
annotableElements
,
1
,
1
);
writeSampleAndAnnotated
(
new
File
(
dataDir
,
sampleFilename
),
new
File
(
dataDir
,
annontatedFilename
),
annotateIndexes
,
associationElements
,
annotableElements
);
}
...
...
@@ -116,7 +117,7 @@ public class PreprocessingRunner implements ApplicationRunner {
return
associationElements
;
}
private
List
<
AssociationElement
>
removeFirstSmallCounts
(
List
<
AssociationElement
>
associationElements
,
int
userSize
,
int
itemSize
)
{
private
List
<
AssociationElement
>
removeFirstSmallCounts
(
List
<
AssociationElement
>
associationElements
)
{
boolean
removedUser
;
boolean
removedItem
;
...
...
@@ -132,7 +133,7 @@ public class PreprocessingRunner implements ApplicationRunner {
itemIdSet
=
associationElements
.
stream
().
map
(
element
->
element
.
getItemId
()).
collect
(
Collectors
.
toSet
());
for
(
Long
itemId
:
itemIdSet
)
{
userCount
=
associationElements
.
stream
().
filter
(
element
->
element
.
getItemId
()
==
itemId
).
count
();
if
(
userCount
<=
userSize
)
{
if
(
userCount
<=
annotateThreshold
)
{
associationElements
=
associationElements
.
stream
().
filter
(
element
->
element
.
getItemId
()
!=
itemId
).
collect
(
Collectors
.
toList
());
if
(!
removedItem
)
{
removedItem
=
true
;
...
...
@@ -149,7 +150,7 @@ public class PreprocessingRunner implements ApplicationRunner {
userIdSet
=
associationElements
.
stream
().
map
(
element
->
element
.
getUserId
()).
collect
(
Collectors
.
toSet
());
for
(
Long
userId
:
userIdSet
)
{
itemCount
=
associationElements
.
stream
().
filter
(
element
->
element
.
getUserId
()
==
userId
).
count
();
if
(
itemCount
<=
itemSize
)
{
if
(
itemCount
<=
annotateThreshold
)
{
associationElements
=
associationElements
.
stream
().
filter
(
element
->
element
.
getUserId
()
!=
userId
).
collect
(
Collectors
.
toList
());
if
(!
removedUser
)
{
removedUser
=
true
;
...
...
@@ -314,6 +315,11 @@ public class PreprocessingRunner implements ApplicationRunner {
annotatePercent
=
1.0f
;
}
if
(
properties
.
containsKey
(
"annotateThreshold"
))
{
annotateThreshold
=
Integer
.
parseInt
(
properties
.
getProperty
(
"annotateThreshold"
));
}
else
{
annotateThreshold
=
1
;
}
}
catch
(
IOException
e
)
{
throw
new
PreprocessingException
(
"Can't read parameters properties file "
+
dataDir
+
parametersFilename
,
e
);
}
...
...
Please
register
or
login
to post a comment