Пример #1
0
        ///
        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);
            }
        }
Пример #2
0
        ///
        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);
            }
        }
Пример #3
0
        ///
        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);
            }
        }
Пример #4
0
        [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));
        }
Пример #5
0
 ///
 public override void Train()
 {
     base.Train();
     this.correlation = BinaryCosine.Create(user_attributes);
 }
Пример #6
0
 ///
 public override void Train()
 {
     base.Train();
     this.correlation = BinaryCosine.Create(data_user);
 }
Пример #7
0
 ///
 public override void Train()
 {
     base.Train();
     this.correlation = BinaryCosine.Create(data_item);
     this.GetPositivelyCorrelatedEntities = Utils.Memoize <int, IList <int> >(correlation.GetPositivelyCorrelatedEntities);
 }