// Set Operation: Union public void unionWith(DataSet otherDataSet) { foreach (long tweet in otherDataSet.egoLikedTweetsInTimeline) this.egoLikedTweetsInTimeline.Add(tweet); foreach (long tweet in otherDataSet.egoUnLikedTweetsInTimeline) this.egoUnLikedTweetsInTimeline.Add(tweet); foreach (long tweet in otherDataSet.timeline) this.timeline.Add(tweet); }
// Return: K-fold 'trainset' and 'testset' public void setTrainTestSet(int index) { this.trainSet = new DataSet(); this.testSet = dataSets[index]; // TestSet Setting this.testSet.clearEgoLikedTweets(); for (int i = 0; i < this.dataSets.Length; i++) { if (i != index) trainSet.unionWith(dataSets[i]); } // Total Ego liked tweets within timebound of the timeline egoUser.updateLikedTweets(); // Recharge Liked Tweets: for another kfold validation foreach (long tweet in egoUser.getLikedTweets()) { if (testSet.isInTimebound(tweet)) { testSet.addEgoLikedTweet(tweet); egoUser.deleteLikedTweet(tweet); // Assure candidate tweets are not liked yet by Ego User } else { trainSet.addEgoLikedTweet(tweet); } } // Only Recommend on Ego: |Likes of Ego in TrainSet| >= threshold double egoLikeThresholdInTestSet = Program.egoLikeThresholdRatioInTestSet * (trainSet.getCntEgoLikedTweets() + testSet.getCntEgoLikedTweets()); if (testSet.getCntEgoLikedTweets() < Math.Floor(egoLikeThresholdInTestSet)) Program.isValidTrainSet = false; else Program.isValidTrainSet = true; }