static void displayStats() { if (training_time_stats.size() > 0) // TODO format floating point System.out.println( "Iteration time: min=" + Collections.min(training_time_stats) + ", max=" + Collections.max(training_time_stats) + ", avg=" + Utils.average(training_time_stats) + " seconds"); if (eval_time_stats.size() > 0) System.out.println( "Evaluation time: min=" + Collections.min(eval_time_stats) + ", max=" + Collections.max(eval_time_stats) + ", avg=" + Utils.average(eval_time_stats) + " seconds"); if (compute_fit && fit_time_stats.size() > 0) System.out.println( "fit_time: min=" + Collections.min(fit_time_stats) + ", max=" + Collections.max(fit_time_stats) + ", avg=" + Utils.average(fit_time_stats) + " seconds"); System.out.println("Memory: " + Memory.getUsage() + " MB"); }
static void loadData( String data_dir, String user_attributes_file, String item_attributes_file, String user_relation_file, String item_relation_file, boolean static_data) throws Exception { long start = Calendar.getInstance().getTimeInMillis(); // Read training data if ((recommender instanceof TimeAwareRatingPredictor || chronological_split != null) && file_format != RatingFileFormat.MOVIELENS_1M) { training_data = TimedRatingData.read( Utils.combine(data_dir, training_file), user_mapping, item_mapping, false); } else { if (file_format == RatingFileFormat.DEFAULT) training_data = static_data ? StaticRatingData.read( Utils.combine(data_dir, training_file), user_mapping, item_mapping, rating_type, false) : RatingData.read( Utils.combine(data_dir, training_file), user_mapping, item_mapping, false); else if (file_format == RatingFileFormat.IGNORE_FIRST_LINE) training_data = static_data ? StaticRatingData.read( Utils.combine(data_dir, training_file), user_mapping, item_mapping, rating_type, true) : RatingData.read( Utils.combine(data_dir, training_file), user_mapping, item_mapping, true); else if (file_format == RatingFileFormat.MOVIELENS_1M) training_data = MovieLensRatingData.read( Utils.combine(data_dir, training_file), user_mapping, item_mapping); else if (file_format == RatingFileFormat.KDDCUP_2011) training_data = org.mymedialite.io.kddcup2011.Ratings.read(Utils.combine(data_dir, training_file)); } recommender.setRatings(training_data); // User attributes if (user_attributes_file != null) user_attributes = AttributeData.read( Utils.combine(data_dir, user_attributes_file), user_mapping, attribute_mapping); if (recommender instanceof IUserAttributeAwareRecommender) ((IUserAttributeAwareRecommender) recommender).setUserAttributes(user_attributes); // Item attributes if (item_attributes_file != null) item_attributes = AttributeData.read( Utils.combine(data_dir, item_attributes_file), item_mapping, attribute_mapping); if (recommender instanceof IItemAttributeAwareRecommender) ((IItemAttributeAwareRecommender) recommender).setItemAttributes(item_attributes); // User relation if (recommender instanceof IUserRelationAwareRecommender) { ((IUserRelationAwareRecommender) recommender) .setUserRelation( RelationData.read(Utils.combine(data_dir, user_relation_file), user_mapping)); System.out.println( "relation over " + ((IUserRelationAwareRecommender) recommender).numUsers() + " users"); } // Item relation if (recommender instanceof IItemRelationAwareRecommender) { ((IItemRelationAwareRecommender) recommender) .setItemRelation( RelationData.read(Utils.combine(data_dir, item_relation_file), item_mapping)); System.out.println( "relation over " + ((IItemRelationAwareRecommender) recommender).getNumItems() + " items"); } // Read test data if (test_file != null) { if (recommender instanceof TimeAwareRatingPredictor && file_format != RatingFileFormat.MOVIELENS_1M) test_data = TimedRatingData.read( Utils.combine(data_dir, test_file), user_mapping, item_mapping, false); else if (file_format == RatingFileFormat.MOVIELENS_1M) test_data = MovieLensRatingData.read( Utils.combine(data_dir, test_file), user_mapping, item_mapping); else if (file_format == RatingFileFormat.KDDCUP_2011) test_data = org.mymedialite.io.kddcup2011.Ratings.read(Utils.combine(data_dir, training_file)); else test_data = StaticRatingData.read( Utils.combine(data_dir, test_file), user_mapping, item_mapping, rating_type, file_format == RatingFileFormat.IGNORE_FIRST_LINE); } System.out.println( "Loading time: " + (double) (Calendar.getInstance().getTimeInMillis() - start) / 1000 + " seconds"); System.out.println("Memory: " + Memory.getUsage() + " MB"); }