Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reccomendFor empty array #35

Closed
gsmeros opened this issue Oct 11, 2015 · 11 comments
Closed

reccomendFor empty array #35

gsmeros opened this issue Oct 11, 2015 · 11 comments

Comments

@gsmeros
Copy link

gsmeros commented Oct 11, 2015

No description provided.

@guymorita
Copy link
Owner

How many ratings were there? Has user 1 already rated everything?


Sent from Mailbox

On Sat, Oct 10, 2015 at 8:47 PM, George Smeros notifications@github.com
wrote:

var raccoon = require('raccoon');
var mysql = require('mysql');
var connection = mysql.createConnection({
...
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
raccoon.connect(6379, '127.0.0.1');
connection.query('SELECT * FROM ratings' , function (error, results, fields) {
for (var i = 0; i < results.length; i++) {
if (results[i].rating > 2) {
raccoon.liked(results[i].userId, results[i].movieId, function () {
console.log("t");
});
} else {
raccoon.disliked(results[i].userId, results[i].movieId, function () {
});
}
}
raccoon.recommendFor(1, 1 , function(results){
console.log(results);
});
});

there is a user 1 but I get an empty array

Reply to this email directly or view it on GitHub:
#35

@gsmeros
Copy link
Author

gsmeros commented Oct 12, 2015

i am looping a query and insert ratings . if i use then the users ratings and then recommend it works fine! but it seems that I have problems with async because I get out of memory and node keeps running 100%cpu. my code :

connection.query('SELECT * FROM ratings', function (error, results, fields) {
results.forEach(function(user){
if (user.rating < 3)
raccoon.disliked(user.userId, user.movieId, function() {});
else
raccoon.liked(user.userId, user.movieId, function() {});
});
connection.end();

if it is a loop , where can I put the recommendFor ?

@gsmeros
Copy link
Author

gsmeros commented Oct 12, 2015

I also tried this :
{connection.query('SELECT * FROM ratings, function (error, results, fields) {
async.parallel([
function(done) {
console.log("Updating Engine");
results.forEach(function(user){
if (user.rating < 3)
raccoon.disliked(user.userId, user.movieId, function() {});
else
raccoon.liked(user.userId, user.movieId, function() {});
});
done(null);
}], function (err) {
response.send("finished");
});
});}

@gsmeros
Copy link
Author

gsmeros commented Oct 13, 2015

Also the redis server keys * :

  1. "movie:2788:liked"
  2. "movie:3880:disliked"
  3. "movie:1226:liked"
  4. "movie:592:liked"
  5. "movie:3508:liked"
  6. "movie:2353:liked"
  7. "movie:317:liked"

@gsmeros
Copy link
Author

gsmeros commented Oct 13, 2015

sorry for the trouble. I manage to fix mostly everything with alternative code. but it seems that my database ( 100.000 ratings from movielens ) is too big to uploaded into redis. It crashes after 13-14k entries

@guymorita
Copy link
Owner

it looks like every set should be able to hold 2^32,
http://redis.io/topics/faq

sure that's it? what was the fix? thanks for keeping me in the loop!

On Tue, Oct 13, 2015 at 10:11 AM, George Smeros notifications@github.com
wrote:

sorry for the trouble. I manage to fix mostly everything with alternative
code. but it seems that my database ( 100.000 ratings from movielens ) is
too big to uploaded into redis. It crashes after 13-14k entries


Reply to this email directly or view it on GitHub
#35 (comment)
.

Guy Morita

T 206.240.5846 l guymorita@gmail.com guymorita@gmail.com

LinkedIn http://www.linkedin.com/in/guymorita l Github
https://github.com/guymorita l Developer Blog
http://guymorita.tumblr.com l Svbtle http://alchemist.svbtle.com

@gsmeros
Copy link
Author

gsmeros commented Oct 14, 2015

If I use this if statement and then try to recommendFor in the callback it doesnt work. Redis is still storing in the background. So what I did i am just trying to put everything up from my training dataset into redis.(Stops at 13k keys) then with every like/dislike of the user I return the updated recommendset. I think maybe Redis can handle the request but node is crashing while it tries to store. Probably a memory issue in my end , but the macbook I am using has no problems...

@gsmeros
Copy link
Author

gsmeros commented Oct 15, 2015

I used a remote server and in a 100.000 ratings table (movie lens) I got 13.8k keys into redis. is this correct ? does this count movieIds only ?

@joshbedo
Copy link

Same thing happened to me, I simply put code in my test that was displayed in the example. I logged into my redis server and made sure that the keys do exist. Here is the code i have.

NOTE: I'm connecting to a docker container by the docker machine ip address so its a remote connection

var expect = require('chai').expect;
var raccoon = require('raccoon');
raccoon.connect(6379, '192.168.99.100');

describe('this doesnt work', function() {

  before(function(done) {
    raccoon.flush();
    done();
  });

  before(function(done) {
    raccoon.liked('garyId', 'movieId');
    raccoon.liked('garyId', 'movie2Id');
    raccoon.liked('chrisId', 'movieId');
    done();
  });

  it('should show movie2', function(done) {
    raccoon.recommendFor('chrisId', 10, function(results) {
      console.log(results, 'results'); // empty array returned
      expect(true).to.eq(false);
      done();
    })
  });
})

@guymorita
Copy link
Owner

@joshbedo I updated the readme to show that the liked /disliked calls are async. They now use promises. So if you call recommendFor before they resolve, you won't get any recommendations.

@guymorita
Copy link
Owner

@gsmeros I'm going to try the Movielens database as well and I'll let you know what the results are!

For every user there are:
liked lists
disliked lists
similarity sets
recommendation sets

For every item there are:
liked lists
disliked lists

Others include:
most liked set
most disliked set
overall score

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants