Baseline method for rating prediction

Uses the average rating value, plus a regularized user and item bias for prediction.

The method was described in section 2.1 of the paper below. One difference is that we support several iterations of alternating optimization, instead of just one.

The optimization problem solved by the Train() method is the following: \f[ \min_{\mathbf{a}, \mathbf{b}} \sum_{(u, i, r) \in R} (r - \mu_R - a_u - b_i)^2 + \lambda_1 \|\mathbf{a}\|^2 + \lambda_2 \|\mathbf{b}\|^2, \f] where \f$R\f$ are the known ratings, and \f$\lambda_1\f$ and \f$\lambda_2\f$ are the regularization constants RegU and RegI. The sum represents the least squares error, while the two terms starting with \f$\lambda_1\f$ and \f$\lambda_2\f$, respectively, are regularization terms that control the parameter sizes to avoid overfitting. The optimization problem is solved an alternating least squares method.

Literature: Yehuda Koren: Factor in the Neighbors: Scalable and Accurate Collaborative Filtering, Transactions on Knowledge Discovery from Data (TKDD), 2009. http://public.research.att.com/~volinsky/netflix/factorizedNeighborhood.pdf

This recommender supports incremental updates.

Inheritance: MyMediaLite.RatingPrediction.IncrementalRatingPredictor, IIterativeModel
コード例 #1
0
    public static void Main(string[] args)
    {
        // load the data
        var user_mapping = new EntityMapping();
        var item_mapping = new EntityMapping();
        var training_data = MyMediaLite.IO.RatingPrediction.Read(args[0], user_mapping, item_mapping);
        var test_data = MyMediaLite.IO.RatingPrediction.Read(args[1], user_mapping, item_mapping);

        // set up the recommender
        var recommender = new UserItemBaseline();
        recommender.Ratings = training_data;
        recommender.Train();

        // measure the accuracy on the test data set
        var results = RatingEval.Evaluate(recommender, test_data);
        Console.WriteLine("RMSE={0} MAE={1}", results["RMSE"], results["MAE"]);

        // make a prediction for a certain user and item
        Console.WriteLine(recommender.Predict(user_mapping.ToInternalID(1), item_mapping.ToInternalID(1)));
    }
コード例 #2
0
	public static void Main(string[] args)
	{
		// load the data
		var training_data = RatingData.Read(args[0]);
		var test_data = RatingData.Read(args[1]);

		// set up the recommender
		var recommender = new UserItemBaseline();
		recommender.Ratings = training_data;
		recommender.Train();

		// measure the accuracy on the test data set
		var results = recommender.Evaluate(test_data);
		Console.WriteLine("RMSE={0} MAE={1}", results["RMSE"], results["MAE"]);
		Console.WriteLine(results);

		// make a prediction for a certain user and item
		Console.WriteLine(recommender.Predict(1, 1));
		
		var bmf = new BiasedMatrixFactorization {Ratings = training_data};
		Console.WriteLine(bmf.DoCrossValidation());
	}