ComputeCorrelation() public method

public ComputeCorrelation ( IRatings ratings, EntityType entity_type, float>.IList entity_ratings, int j ) : float
ratings IRatings
entity_type EntityType
entity_ratings float>.IList
j int
return float
Ejemplo n.º 1
0
		[Test()] public void TestComputeCorrelation()
		{
			// create test objects
			var ratings = new Ratings();
			ratings.Add(0, 1, 0.3f);
			ratings.Add(0, 4, 0.2f);
			ratings.Add(1, 2, 0.6f);
			ratings.Add(1, 3, 0.4f);
			ratings.Add(1, 4, 0.2f);

			// test
			var p = new Pearson(ratings.AllUsers.Count, 0f);
			Assert.AreEqual(0, p.ComputeCorrelation(ratings, EntityType.USER, 0, 1));
		}
Ejemplo n.º 2
0
		[Test()] public void TestComputeCorrelations2()
		{
			// load data from disk
			var user_mapping = new Mapping();
			var item_mapping = new Mapping();
			var ratings = RatingData.Read("../../../../data/ml-100k/u1.base", user_mapping, item_mapping);
			
			var p = new Pearson(ratings.AllUsers.Count, 200f);
			Assert.AreEqual(-0.02788301f, p.ComputeCorrelation(ratings, EntityType.ITEM, 45, 311), 0.00001);
		}