relational learning error self prediction(user,itemrating abs_error +abs(errorsumsq_error +error error return abs_error/len(ratings)sumsq_error/len(ratingsalternative formulation an alternative formulation is to regularize after each update plotting relncollfilt py -(continued def plot_predictions(selfexamples="test")""examples is either "testor "trainingor the actual examples ""if examples ="test"examples self test_ratings elif examples ="training"examples self ratings plt ion(plt xlabel("prediction"plt ylabel("cumulative proportion"self actuals [[for in range( , )for (user,item,rating,timestampin examplesself actuals[ratingappend(self prediction(user,item)for rating in range( , )self actuals[ratingsort(numrat=len(self actuals[rating]yvals [ /numrat for in range(numrat)plt plot(self actuals[rating]yvalslabel="rating="+str(rating)plt legend(plt draw(this plots single property each (useritemratingis plotted where the -value is the value of the property for the userthe -value is the value of the property for the itemand the rating is plotted at this (xyposition that israting is plotted at the (xyposition ( (user) (item)relncollfilt py -(continued def plot_property(selfpproperty plot_all=falsetrue if all points should be plotted num_points= number of random points plotted if not all )"""plot some of the user-movie ratingsversion june