guoguibing / librec

LibRec: A Leading Java Library for Recommender Systems, see
https://www.librec.net/
Other
3.23k stars 1.03k forks source link

how do I output the predict results only in the testset #280

Open danyang-liu opened 5 years ago

danyang-liu commented 5 years ago

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.

SunYatong commented 5 years ago

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);
    }
ran88dom99 commented 5 years ago

Can predict() be run form command line?

danyang-liu commented 5 years ago

Hi SunYatong: Thanks, I will try.

mvijaikumar commented 5 years ago

Can we predict values for a test set from the command line?

mvijaikumar commented 5 years ago

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?

SunYatong commented 5 years ago

@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);
    }
mvijaikumar commented 5 years ago

@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?

SunYatong commented 5 years ago

So you want to get the prediction of arbitrary user-item pairs? @mvijaikumar

mvijaikumar commented 5 years ago

I want to predict rating for user and item that is part of training set, however, the exact pair is not a part of training set. That is, user is part of training set, itme is part of training set.

On Mon, Feb 11, 2019, 17:45 SunYatong <notifications@github.com wrote:

So you want to get the prediction of arbitrary user-item pairs?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/guoguibing/librec/issues/280#issuecomment-462307537, or mute the thread https://github.com/notifications/unsubscribe-auth/AeROdZSWIathgc6vjU4ZVqZ5Ud9tg48Oks5vMV74gaJpZM4XbJ9G .

mvijaikumar commented 5 years ago

I want to predict rating for user and item that is part of training set, however, the exact pair is not a part of training set. That is, user is part of training set, item is part of training set.

On Mon, Feb 11, 2019, 17:45 SunYatong <notifications@github.com wrote:

So you want to get the prediction of arbitrary user-item pairs?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/guoguibing/librec/issues/280#issuecomment-462307537, or mute the thread https://github.com/notifications/unsubscribe-auth/AeROdZSWIathgc6vjU4ZVqZ5Ud9tg48Oks5vMV74gaJpZM4XbJ9G .

SunYatong commented 5 years ago

So you do want to get the prediction of arbitrary user-item pairs... @mvijaikumar

Just use

 predict(userIdx, itemIdx)