Exemple #1
0
        public void TestShowArticles()
        {
            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);
            (var topPatterns, var patternNames) = newsFeatures.ShowFeatures(weights, feat, artT, wordVec);
            newsFeatures.ShowArticles(artT, topPatterns, patternNames);
        }
Exemple #2
0
        public void TestArticleFactorize()
        {
            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);
            TestOutput(weights);
            TestOutput(feat);
        }
Exemple #3
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);
        }