/// public override void Train() { correlation = BinaryCosine.Create(user_attributes); int num_users = user_attributes.NumberOfRows; this.nearest_neighbors = new int[num_users][]; for (int u = 0; u < num_users; u++) { nearest_neighbors[u] = correlation.GetNearestNeighbors(u, k); } }
/// public override void Train() { this.correlation = BinaryCosine.Create(Feedback.UserMatrix); int num_users = MaxUserID + 1; this.nearest_neighbors = new int[num_users][]; for (int u = 0; u < num_users; u++) { nearest_neighbors[u] = correlation.GetNearestNeighbors(u, k); } }
/// public override void Train() { correlation = BinaryCosine.Create(Feedback.ItemMatrix); int num_items = MaxItemID + 1; this.nearest_neighbors = new int[num_items][]; for (int i = 0; i < num_items; i++) { nearest_neighbors[i] = correlation.GetNearestNeighbors(i, k); } }
[Test()] public void TestCreate() { // create test objects var sparse_boolean_matrix = new SparseBooleanMatrix(); sparse_boolean_matrix[0, 1] = true; sparse_boolean_matrix[0, 4] = true; sparse_boolean_matrix[1, 0] = true; sparse_boolean_matrix[1, 2] = true; sparse_boolean_matrix[1, 4] = true; sparse_boolean_matrix[3, 1] = true; sparse_boolean_matrix[3, 3] = true; sparse_boolean_matrix[3, 4] = true; // test var correlation_matrix = BinaryCosine.Create(sparse_boolean_matrix); Assert.AreEqual(Math.Round(1 / Math.Sqrt(6), 4), Math.Round(correlation_matrix[0, 1], 4)); Assert.AreEqual(Math.Round(1 / Math.Sqrt(6), 4), Math.Round(correlation_matrix[1, 0], 4)); Assert.AreEqual(Math.Round(1 / 3d, 4), Math.Round(correlation_matrix[1, 3], 4)); }
/// public override void Train() { base.Train(); this.correlation = BinaryCosine.Create(user_attributes); }
/// public override void Train() { base.Train(); this.correlation = BinaryCosine.Create(data_user); }
/// public override void Train() { base.Train(); this.correlation = BinaryCosine.Create(data_item); this.GetPositivelyCorrelatedEntities = Utils.Memoize <int, IList <int> >(correlation.GetPositivelyCorrelatedEntities); }