Exemplo n.º 1
0
        [Test()] public void TestColumnAverage()
        {
            var matrix = new Matrix <double>(5, 5);

            double[] row = { 1, 2, 3, 4, 5 };
            for (int i = 0; i < 5; i++)
            {
                matrix.SetRow(i, row);
            }
            Assert.AreEqual(2.0, MatrixUtils.ColumnAverage(matrix, 1));
            Assert.AreEqual(5.0, MatrixUtils.ColumnAverage(matrix, 4));
        }
Exemplo n.º 2
0
        ///
        public override void LearnAttributeToFactorMapping()
        {
            this.factor_bias = new double[num_factors];

            for (int i = 0; i < num_factors; i++)
            {
                factor_bias[i] = MatrixUtils.ColumnAverage(item_factors, i);
                Console.Error.WriteLine("fb {0}: {1}", i, factor_bias[i]);
            }

            this.attribute_to_factor = new Matrix <double>(NumItemAttributes, num_factors);
            MatrixUtils.InitNormal(attribute_to_factor, InitMean, InitStdev);

            for (int i = 0; i < num_iter_mapping; i++)
            {
                IterateMapping();
            }

            _MapToLatentFactorSpace = Utils.Memoize <int, double[]>(__MapToLatentFactorSpace);
        }