Skip to content

Movielens: getnnz() got an unexpected keyword argument 'axis' #87

Closed

Description

@ricardoatsouza

Hello,
I just started playing around with lightFM, so this can be something that I just missed while trying the Movielens example.

Here is the code that I did following the tutorial available on this link
import numpy as np
from lightfm.datasets import fetch_movielens # movielens dataset
from lightfm.evaluation import * # precision_at_k
from lightfm import *

movielens = fetch_movielens()

train = movielens['train']
test = movielens['test']

model = LightFM(learning_rate=0.05, loss='bpr')

model.fit(train, epochs=10)

train_precision = precision_at_k(model, train, k=10).mean()
test_precision = precision_at_k(model, test, k=10).mean()

train_auc = auc_score(model, train).mean()
test_auc = auc_score(model, test).mean()

print('Precision: train %.2f, test %.2f.' % (train_precision, test_precision))
print('AUC: train %.2f, test %.2f.' % (train_auc, test_auc))

I'm getting this error as output:

Traceback (most recent call last):
File "main.py", line 17, in <module>
train_precision = precision_at_k(model, train, k=10).mean()
File "/Library/Python/2.7/site-packages/lightfm/evaluation.py", line 70, in precision_at_k
precision = precision[test_interactions.getnnz(axis=1) > 0]
TypeError: getnnz() got an unexpected keyword argument 'axis'

I'm fairly thinking that it's a silly mistake from my code; but because I couldn't figure it out, I'm opening this issue.

Thanks!

Activity

  1. maciejkula commented on May 26, 2016

    @maciejkula
    Collaborator

    Thanks for the report --- can you post what your version of scipy is?

  2. ricardoatsouza commented on May 27, 2016

    @ricardoatsouza
    Author

    Thanks for your reply, and sorry for my late reply.
    Scipy version is 0.13.0b1

    I found out by executing:
    import scipy
    scipy.__version__

  3. maciejkula commented on May 27, 2016

    @maciejkula
    Collaborator

    You should upgrade to a newer version of scipy, >= 0.17.0. I will change the requirements file to reflect this.

  4. ricardoatsouza commented on May 27, 2016

    @ricardoatsouza
    Author

    I wasn't aware that my SciPy version was too old.
    I updated it and, indeed, that was the problem.

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions