NicolasHug / Surprise

A Python scikit for building and analyzing recommender systems
http://surpriselib.com
BSD 3-Clause "New" or "Revised" License
6.36k stars 1.01k forks source link

[FIX] NMF: Handle 0 ratings #367

Closed VesnaT closed 2 years ago

VesnaT commented 4 years ago
Issue

NMF crashed with ZeroDivisionError: float division when all ratings for a user (or. an item) were 0.

Description of changes

Fix sgd() to skip update step when the rating is 0.

Alternative approach

The rating could be 'fixed' to a very small number to enable further updates.

DavidChenLondon commented 4 years ago

LGTM, I'm also experiencing the same error.