Example #1
0
        public void TestShowFeatures()
        {
            var newsFeatures = new NewsFeatures();

            (var allW, var artW, var artT) = newsFeatures.GetArticleWords();
            (var wordMatrix, var wordVec)  = newsFeatures.MakeMatrix(allW, artW);
            var nmf    = new Nmf(o => TestOutput(o.ToString()));
            var matrix = DenseMatrix.OfRows(wordMatrix);

            (var weights, var feat) = nmf.Factorize(matrix, 20, 50);
            newsFeatures.ShowFeatures(weights, feat, artT, wordVec);
        }
Example #2
0
        public void TestFactorize()
        {
            var m1 = DenseMatrix.OfArray(new[, ] {
                { 1d, 2d, 3d }, { 4d, 5d, 6d }
            });
            var m2 = DenseMatrix.OfArray(new[, ] {
                { 1d, 2d }, { 3d, 4d }, { 5d, 6d }
            });
            var m12 = m1 * m2;

            TestOutput(m12);

            var nmf = new Nmf(o => TestOutput(o.ToString()));

            (var w, var h) = nmf.Factorize(m12, 3, 100);
            TestOutput(w);
            TestOutput(h);
            TestOutput(w * h);
        }