Implementing user ratings
Many online vendors ask their customers to rate the products that they purchase, typically on a scale of one to five stars. We can modify our previous Recommender2
program to incorporate these numerical ratings. To test the new version, we'll also modify our DataGenerator
and Filter
programs.
The modified DataGenerator
program is shown in Listing 9.18:
(The folded code is the same as in the DataGenerator1
program in Listing 9.2.) It creates random ratings from the set {1.0, 1.5, 2.0, 2.5, …, 5.0} that are normally distributed with mean 3.0 and standard deviation 1.0.
The only modifications needed for the Filter
program are changing int
to double
where necessary. The results from a sample run are shown in Figure 9.10 and Figure 9.11:
Item #9 has not been bought by anyone—all five of its entries in the utility matrix are 0.0. Consequently...