relational learning lines (line decode('utf- 'for line in urllib request urlopen(url)all_ratings (tuple(int(efor in line strip(split('\ ')for line in linesself training_ratings [self training_stats { : : : : , : self test_ratings [self test_stats { : : : : , : for rate in all_ratingsif rate[ date_splitrate[ is timestamp self training_ratings append(rateself training_stats[rate[ ]+ elseself test_ratings append(rateself test_stats[rate[ ]+ self display( ,read:"len(self training_ratings),"training ratings and"len(self test_ratings),"test ratings"tr_users {user for (user,item,rating,timestampin self training_ratingstest_users {user for (user,item,rating,timestampin self test_ratingsself display( ,"users:",len(tr_users),"training,",len(test_users),"test,"len(tr_users test_users),"in common"tr_items {item for (user,item,rating,timestampin self training_ratingstest_items {item for (user,item,rating,timestampin self test_ratingsself display( ,"items:",len(tr_items),"training,",len(test_items),"test,"len(tr_items test_items),"in common"self display( ,"rating statistics for training set",self training_statsself display( ,"rating statistics for test set",self test_statssometimes it is useful to plot property for all (useritemratingtriples there are too many such triples in the data set the method create top subset creates much smaller dataset where this makes sense it picks the most rated itemsthen picks the users who have the most ratings on these items it is designed for depicting the meaning of propertiesand may not be useful for other purposes relncollfilt py -(continued def create_top_subset(selfnum_items num_users )"""returns subset of the ratings by picking the most rated itemsand then the users that have most ratings on theseand then all of the ratings that involve these users and items ""items {item for (user,item,rating,timestampin self training_ratings version june