Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow to build fature-based recommender from empty vector #12

Merged
merged 3 commits into from
Jan 20, 2022
Merged

Conversation

takuti
Copy link
Owner

@takuti takuti commented Jan 19, 2022

Originally, user, item, and contextual features were initialized with a dummy element np.array([0.]) to avoid errors associated with empty array manipulation. This workaround added unnecessary dimensions to the input vectors and caused a failure in a simple case like:

  recommender = FMRecommender(p=3)
  recommender.initialize()

  user = User(0)  # -> dummy user feature: np.array([0.])
  recommender.register(user)

  item = Item(0)  # -> dummy item feature: np.array([0.])
  recommender.register(item)

  # Eventually, the num of dimensions of a feature vector corresponding
  # to the event is # 5 (1 user dummy + 1 item dummy + 3 contextual),
  # which differs from `p=3`.
  event = Event(user, item, context=np.array([0, 4, 0]))
  recommender.update(event)  # -> FAILED

Fix #10

Originally, user, item, and contextual features were initialized with a
dummy element `np.array([0.])` to avoid errors associated with empty
array manipulation. This workaround added unneccessary dimensions to the
input vectors and caused a failure in a simple case like:

  recommender = FMRecommender(p=3)
  recommender.initialize()

  user = User(0)  # -> dummy user feature: np.array([0.])
  recommender.register(user)

  item = Item(0)  # -> dummy item feature: np.array([0.])
  recommender.register(item)

  # Eventually, the num of dimensions of a feature vector corresponding
  # to the event is # 5 (1 user dummy + 1 item dummy + 3 contextual),
  # which differs from `p=3`.
  event = Event(user, item, context=np.array([0, 4, 0]))
  recommender.update(event)
Recommender should be functional as long as either user, item, or
contextual features is non-empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: no supported conversion for types: (dtype('<U32'),)
1 participant