Skip to content

Commit

Permalink
Implemented Holdout and Cross-validation procedure with validation se…
Browse files Browse the repository at this point in the history
…t generation.
  • Loading branch information
aleSuglia committed Nov 21, 2016
1 parent 40310da commit e7d347f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ public class RandomSplitter<U, I> implements Splitter<U, I> {
* either on the training or on the test split
*/
public RandomSplitter(final float percentageTrainingRatio, final boolean perUserFlag, final long seed, final boolean doSplitPerItemsFlag) {
if (this.perUser && !this.doSplitPerItems) {
throw new IllegalArgumentException("Invalid combination perUser: True and doSplitPerItems: False");
}
this.percentageTraining = percentageTrainingRatio;
this.perUser = perUserFlag;
this.doSplitPerItems = doSplitPerItemsFlag;

rnd = new Random(seed);
}

Expand Down Expand Up @@ -95,8 +97,6 @@ public DataModelIF<U, I>[] split(final DataModelIF<U, I> data) {
datamodel.addPreference(user, item, pref);
}
}
} else {
// Combination not available
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void testValidationCV() {
assertTrue(!splits[0].getUserItemPreferences().containsKey(userValid) || !splits[0].getUserItemPreferences().get(userValid).containsKey(itemValid));
// Let's check this pair is not in its corresponding test split
assertTrue(!splits[2].getUserItemPreferences().containsKey(userValid) || !splits[2].getUserItemPreferences().get(userValid).containsKey(itemValid));

}


Expand Down

0 comments on commit e7d347f

Please sign in to comment.