Comments (3)
You need to pass user_features to the predict call as well (or auc_score as
is the case here).
On 19 Sep 2016 11:38, "Andre" [email protected] wrote:
I'm trying to fit a very basic instance of LightFM
model = LightFM(loss='warp')
model = model.fit(df, user_features=user_features)Where it should be noted that df.shape = (222113, 2269), and
user_features.shape = (222113, 24). The model object is able to be fitted,
but when I subsequently try to call the auc_score method, I get the
following error.Traceback (most recent call last):
File "main.py", line 35, in
model = engine.fit(train, test, user_features=user_feat)
File "/Users/andre/Playphone/Recommendations/lightfm-engine/engine.py",
line 23, in fit
train_auc = auc_score(model, train, num_threads=self.NUM_THREADS).mean()
File "/Users/andre/miniconda3/envs/py2/lib/python2.7/site-
packages/lightfm/evaluation.py", line 118, in auc_score
num_threads=num_threads)
File "/Users/andre/miniconda3/envs/py2/lib/python2.7/site-packages/lightfm/lightfm.py",
line 649, in predict_rank
item_features)
File "/Users/andre/miniconda3/envs/py2/lib/python2.7/site-packages/lightfm/lightfm.py",
line 235, in _construct_feature_matrices
assert self.user_embeddings.shape[0] >= user_features.shape[1]
AssertionErrorSo I thought, maybe the shapes of the two sparse matrices are different
but as it turns out:
model.user_embeddings.shape[0] = 24
user_features.shape[1] = 24Not really sure what's wrong, because the boolean value of the assert
statement should evaluate to True in this case.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#108, or mute the thread
https://github.com/notifications/unsubscribe-auth/ACSCA8HjUXzmsvUdiUCnLdp0s4jxFhg6ks5qrtbBgaJpZM4KA0rt
.
from lightfm.
Thanks for the quick reply @maciejkula, all is well now.
I have encountered a separate problem though. My user_features matrix is a scipy CSR matrix of type np.float64. If I'm not wrong this is being cast to a C double instead of a flt - and it seems that it is required:
/Users/me/miniconda3/envs/py2/lib/python2.7/site-packages/lightfm/_lightfm_fast.py:9: UserWarning: LightFM was compiled without OpenMP support. Only a single thread will be used.
warnings.warn('LightFM was compiled without OpenMP support. '
Traceback (most recent call last):
File "main.py", line 35, in <module>
model = engine.fit(train, test, user_features=user_features)
File "/path/to/dir/lightfm-engine/engine.py", line 19, in fit
train_auc = auc_score(model, train, user_features=user_features, num_threads=self.NUM_THREADS).mean()
File "/Users/me/miniconda3/envs/py2/lib/python2.7/site-packages/lightfm/evaluation.py", line 118, in auc_score
num_threads=num_threads)
File "/Users/me/miniconda3/envs/py2/lib/python2.7/site-packages/lightfm/lightfm.py", line 675, in predict_rank
CSRMatrix(user_features),
File "lightfm/_lightfm_fast_no_openmp.pyx", line 156, in lightfm._lightfm_fast_no_openmp.CSRMatrix.__init__ (lightfm/_lightfm_fast_no_openmp.c:2339)
ValueError: Buffer dtype mismatch, expected 'flt' but got 'double'
Is there some underlying piece of logic that automatically converts the np.float64 dtype to a double? I apologize for the many questions, just trying to figure things out. Thanks buddy
from lightfm.
This is because your data is a double
(np.float64
), and it expects a float
.
Arguably there should be a piece of code that does the casting automatically if needed. I'd be happy to accept a PR to that effect.
from lightfm.
Related Issues (20)
- How to reproduce the evaluation score in the paper.
- Recommender System with RFM ratings to put into Interaction matrix HOT 9
- Feature Request: Support for Freezing Item Embeddings while Updating User Embeddings During Training
- Incorporating item and user biases in LightFM embeddings for accurate recommendations in Vespa HOT 1
- Item and User Normalization
- Is there a way to save Dataset()? HOT 1
- How to get clusters of users from trained lightfm model on implicit rating model?
- Evaluate AUC on a subset of items
- Auc evalutation return always nan
- Can't install on Python 3.10.6 in Ubuntu HOT 1
- Implementing Incremental Training and Feedback loop using Lightfm
- LightFM kills Jupyter Kernel when fitting model
- Does calculating precision@k for one user makes sense? HOT 1
- Creating recommendations for single users without leveraging user identity features
- Can't install on Python 3.12 HOT 6
- Can't seem to install with with poetry HOT 3
- ModuleNotFoundError: No module named 'lightfm._lightfm_fast_no_openmp'
- Recommendation model with text embedding as item feature
- Same precision@k with different item embeddings?
- Recommending documents to users based on keywords in the absence of interactions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lightfm.