self item_bias get(item, #self item_bias[itemsum([self user_prop get(user,self zeros)[ ]*self item_prop get(item,self zeros)for in range(self num_properties)]) def learn(selfnum_iter )""do num_iter iterations of gradient descent ""for in range(num_iter)self iter + abs_error= sumsq_error= for (user,item,rating,timestampin random sample(self ratings,len(self ratings))error self prediction(user,itemrating abs_error +abs(errorsumsq_error +error error self user_bias[user-self step_size*error self item_bias[item-self step_size*error for in range(self num_properties)self user_prop[user][ -self step_size*error*self item_prop[item][pself item_prop[item][ -self step_size*error*self user_prop[user][pfor user in self usersself user_bias[user-self step_size*self reglzself user_bias[userfor in range(self num_properties)self user_prop[user][ -self step_size*self reglz*self user_prop[user][pfor item in self itemsself item_bias[item-self step_size*self reglz*self item_bias[itemfor in range(self num_properties)self item_prop[item][ -self step_size*self reglz*self item_prop[item][pself display( ,"iteration",self iter"(ave abs,avesumsqtraining =",self evaluate(self ratings)"test =",self evaluate(self test_ratings)evaluate evaluates current predictions on the rating setrelncollfilt py -(continued def evaluate(self,ratings)"""returns (avergage_absolute_erroraverage_sum_squares_errorfor ratings ""abs_error sumsq_error if not ratingsreturn ( , for (user,item,rating,timestampin ratingsversion june