Code Monkey home page Code Monkey logo

bpr's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bpr's Issues

import toydoop

Thanks for sharing your code! A fantastic job!

What is the repository toydoop in presampled_bpr.py? I cannot find this repository?

ps: could you provide us a data sample? That would be best

IndexError: @ random.choice(self.data[u].indices)

sampling 9993 <user,item i,item j> triples...
Traceback (most recent call last):
File "testTopK.py", line 283, in
model.train(data,sampler,num_iters)
File "testTopK.py", line 46, in train
self.init(data)
File "testTopK.py", line 63, in init
self.create_loss_samples()
File "testTopK.py", line 71, in create_loss_samples
self.loss_samples = [t for t in sampler.generate_samples(data,num_loss_samples)]
File "testTopK.py", line 173, in generate_samples
j = self.sample_negative_item(self.data[u].indices)
File "testTopK.py", line 139, in sample_negative_item
j = self.random_item()
File "testTopK.py", line 154, in random_item
i = random.choice(self.data[u].indices)
File "/usr/lib64/python2.7/random.py", line 274, in choice
return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
IndexError: index 0 is out of bounds for axis 0 with size 0

Does input needs to be deduplicated?

Hi Mark thank you for the repository!

I was wondering if a user interacted with an item more than once, do you only keep 1 record of it in the training data? How does BPR distinguish between an item that a user frequently consumed and an item that a user only consumed once or twice? It seems if the input is not deduplicated the more popular item has a higher chance to be chosen at each step thus gives it more importance (which makes sense because the more frequently an item is consumed the more confident we are that the user likes it with no explicit feedback)? But the the input matrix is not a "all-one" matrix anymore and each entry would be the number of times user u consumed item I instead.

Can you help me in understanding this a little bit more? Thank you

Math OverflowError in update_factors

Hello,
I'm trying to use you code to learn and predict on a binary sparse matrix (meaning I only have 1s in the matrix), but during the training phase it will crash and throw this error:
Traceback (most recent call last): File "bpr.py", line 260, in <module> model.train(data,sampler,num_iters) File "bpr.py", line 52, in train self.update_factors(u,i,j) File "bpr.py", line 81, in update_factors z = 1.0/(1.0+exp(x)) OverflowError: math range error

I've checked to see who's guilty of this, and apparently the x variable of the fucntion is diverging, therefore causing the exp operator to overflow.
Have you encountered this issue? Can you suggest a fix?

Thanks

Please help me,why xrange is not defined

Traceback (most recent call last):
File "D:/PycharmProjects/recommendation algorithm/bpr.py", line 289, in
model.train(data,sampler,num_iters)
File "D:/PycharmProjects/recommendation algorithm/bpr.py", line 45, in train
self.init(data)
File "D:/PycharmProjects/recommendation algorithm/bpr.py", line 62, in init
self.create_loss_samples()
File "D:/PycharmProjects/recommendation algorithm/bpr.py", line 70, in create_loss_samples
self.loss_samples = [t for t in sampler.generate_samples(data, num_loss_samples)]
File "D:/PycharmProjects/recommendation algorithm/bpr.py", line 70, in
self.loss_samples = [t for t in sampler.generate_samples(data, num_loss_samples)]
File "D:/PycharmProjects/recommendation algorithm/bpr.py", line 168, in generate_samples
for _ in xrange(self.num_samples(self.data.nnz)):
NameError: name 'xrange' is not defined

BPR optimization criteria

Hi!

Thanks for sharing the code!
I have a question regarding to line 79 file bpr.py :
z = 1.0/(1.0+exp(x))

According to the original BPR paper, it seems to me that there should be something like
z = exp(-x)/(1.0+exp(-x))

Am I missing something? Or are those equations proportionally equal?
Thanks,
Ladislav

Calling sample_negative_item() issue

Thanks for creating this useful project!

After I tested the program, I found one issue in bpr.py file:
At line 204 and 220, sample_negative_item(self.data[u]) ==> sample_negative_item(self.data[u].indices),
which is similar to line 172.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.