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

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

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 5, 2018 in Python by eatcodesleeprepeat
• 4,750 points

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 5, 2018 by Priyaj
• 57,550 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,780 points
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 aryya
• 7,370 points
+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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,206 views
0 votes
0 answers
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, 2019 in Python by rajesh
• 1,230 points