LightFM does the training set need to be the same size as the test set?

0 votes

I'm working on a pure collaborative filtering model in LightFM using a simple user-item matrix.

When I have a training matrix that has more rows than the test matrix, I encounter this error: "Incorrect number of features in user_features"

It seems this is caused by line 789 in lightfm.py:

if not user_features.shape[1] == self.user_embeddings.shape[0]:
    raise ValueError('Incorrect number of features in user_features')

Investigating this - it looks like it is being caused by line 778 in lightfm.py:

n_users, n_items = test_interactions.shape

Which suggests the size of the test dataset should match the train. And making them the same size does fix my error.

How can I persuade LightFM to let me have train and test datasets of different sizes?

Oct 10, 2018 in Python by eatcodesleeprepeat
• 4,670 points
116 views

1 answer to this question.

0 votes

I would change the wording. Often in ML, the rows are the samples and in this interpretation your single row-sample is a tuple or something similar (user, item, value). The number of rows in test and train surely has no limitation! But there is one in terms of dimensions. So only in terms of dimensions (which users and which items are observed) those datasets need a 1:1 correspondence. That's maybe a strong assumption, but you can imagine the problem predicting user 11, where there was no user 11 in training (there is no latent-vector which was build)

answered Oct 10, 2018 by Priyaj
• 56,520 points

Related Questions In Python

0 votes
1 answer

In LightFM does the training set need to be the same size as the test set?

I would change the wording. Often in ML, ...READ MORE

answered Sep 21, 2018 in Python by charlie_brown
• 7,720 points
28 views
0 votes
1 answer
0 votes
1 answer

How to get the size of a string in Python?

If you are talking about the length ...READ MORE

answered Jun 4, 2018 in Python by ariaholic
• 7,340 points
85 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 215 views
0 votes
1 answer
–1 vote
2 answers

How to find the size of a string in Python?

following way to find length of string  x ...READ MORE

answered Mar 29 in Python by rajesh
• 1,210 points
80 views