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); }
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); }
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); }