how do I output the predict results only in the testset
danyang-liu opened this issue · 11 comments
I use BPR. I want to get the predict results for the u-i pairs in testset. But the results in ./result/ is the top_n item_rating for these users, not the items I want to predict.
After training, You can run the predict(int userIdx, itemIdx)
function with the testMatrix.
// after training
for (MatrixEntry me : testMatrix) {
int userIdx = me.row(); // user
int itemIdx = me.column(); // item
double predictRating = predict(userIdx, itemIdx);
}
Can predict() be run form command line?
Hi SunYatong:
Thanks, I will try.
Can we predict values for a test set from the command line?
Can we predict values for a test set from the command line? That is, instead of storing predicted values for training data or top-N values among the whole item set (in case of ranking based recommendation algorithm), can we store predicted values of a given test set from command line?
@mvijaikumar Command line doesn't support this. You can denote the test set before training with TestSetSplitter, and add the code after training.
// after training
for (MatrixEntry me : testMatrix) {
int userIdx = me.row(); // user
int itemIdx = me.column(); // item
double predictRating = predict(userIdx, itemIdx);
}
@SunYatong Thank you for your response. I am facing a peculiar problem in doing so as described above. If (userid, itemid) pair is not a part of a training set, and part of a test set (for obvious reason), testMatrix does not contain that pair.
I tested this on PMFRecommender. I could not understand why it is happening. Can you help me out?
So you want to get the prediction of arbitrary user-item pairs? @mvijaikumar
So you do want to get the prediction of arbitrary user-item pairs... @mvijaikumar
Just use
predict(userIdx, itemIdx)