Closed markdouthwaite closed 3 years ago
Thanks @markdouthwaite.
Looking at the len(user_ids) != len(item_ids)
ValueError, I wonder whether it could use more information about a common scenario that produces the error. I think often users expect lfm.predict(user_ids=[0, 1], item_ids=[7, 6, 5])
to predict items 7, 6, 5
to users 0, 1
but to achieve that one would need to call lfm.predict(user_ids=[0, 0, 0, 1, 1, 1], item_ids=[7, 6, 5, 7, 6, 5]
.
Now that I write it out, this should be made explicit with an example in the method Docstring, not in an error message. Do you agree?
Hey @SimonCW,
Thanks for the response.
this should be made explicit with an example in the method Docstring, not in an error message. Do you agree?
I agree, I'll add a few words to the docstring to clarify that.
Hey!
I've submitted this PR primarily to resolve a minor issue that (I feel) violates 'the principle of least surprise'.
The
predict
method acceptsuser_ids
anditem_ids
parameters. Foritem_ids
, a couple of coercion steps are used to massage the input into andarray
of typenp.int32
. This includes castingitem_ids
of typelist
andtuple
tondarray
as needed. In contrast, ifuser_ids
are provided as a type other thanndarray
, aTypeError
is raised. In other words, if I calllfm.predict(user_ids=[0, 1, 2, 3], item_ids=[7, 6, 5, 4])
would currently throw aTypeError
for the type of theuser_ids
parameter, but not theitem_ids
parameter. This PR ensures parity between the two.I've also switched out the assertion used to check
user_ids
anditem_ids
in favour of a conditional that raises aValueError
instead. I've updated tests accordingly.This PR depends on #587.