public void TestMakeMatrix() { var newsFeatures = new NewsFeatures(); var rssResult = newsFeatures.GetArticleWords(); var matrixTuple = newsFeatures.MakeMatrix(rssResult.Item1, rssResult.Item2); TestOutput(JsonConvert.SerializeObject(matrixTuple.Item2.Take(10))); TestOutput(rssResult.Item3[1]); TestOutput(JsonConvert.SerializeObject(matrixTuple.Item1[1].Take(10))); }
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); }
public void TestMakeMatrix() { var newsFeatures = new NewsFeatures(); (var allW, var artW, var artT) = newsFeatures.GetArticleWords(); (var wordMatrix, var wordVec) = newsFeatures.MakeMatrix(allW, artW); // 单词向量的前10个词 TestOutput(JsonConvert.SerializeObject(wordVec.Take(10))); // 第二篇文章的标题 TestOutput(artT[1]); // 第二篇文章的在单词矩阵中对应的数据行的前10个值 TestOutput(JsonConvert.SerializeObject(wordMatrix[1].Take(10))); }