背景:
进行文本挖掘的时候,无论是聚类还是相似计算首先需要向量化。
思路:
对于某一文本计算完其tf(tf-idf)之后生成word->tf(tf-idf)的对应表,那么构造成向量记做:
v=(a1,a2,…,an) 此为为n维向量。a1...an为tf(tf-idf),同时我们把word转换成int来作为下标。
实现:
/** * vector转换 * * @param map 单词和词频map * @param otherInfo 用于保存的其他信息 * @return Vector */ public static Vector vector(Map<String, Double> map, String otherInfo) { Vector vector = new RandomAccessSparseVector(Integer.MAX_VALUE); NamedVector nv = new NamedVector(vector, otherInfo); Iterator<Entry<String, Double>> iterator = map.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, Double> entry = iterator.next(); nv.setQuick(entry.getKey().hashCode(), entry.getValue()); } return vector; }
PS:可以根据自己的需要选择相应的Vector实现类.
相关推荐
mahout测试数据 raw文件夹下有5目录(camera computer household mobile MP3)每个目录下有1000多篇文章
【甘道夫】通过Mahout构建贝叶斯文本分类器案例详解 -- 配套源码
mahout聚类算法的介绍,例如:Canopy,KMeans,Fuzzy-KMeans,Spectral Clustering等参数介绍和适用场景介绍
mahout_help,mahout的java api帮助文档,可以帮你更轻松掌握mahout
maven_mahout_template-mahout-0.8
相关技术 推荐算法 ...对新闻文本进行分词 调用Deeplearning4j中构建paragraphvector的方法,通过doc2vec构建VSM 用Gensim会更方便点 基于热点的推荐 统计最高浏览量 过滤一定时间前的新闻保证热点的准确
NULL 博文链接:https://snv.iteye.com/blog/2007843
MAHOUT实战 MAHOUT IN ACTION
mahout-examples-0.11.1 mahout-examples-0.11.1-job mahout-h2o_2.10-0.11.1 mahout-h2o_2.10-0.11.1-dependency-reduced mahout-hdfs-0.11.1 mahout-integration-0.11.1 mahout-math-0.11.1 mahout-math-0.11.1 ...
mahoutAlgorithms源码分析 mahout代码解析
mahout-integration-0.7mahout-integration-0.7mahout-integration-0.7mahout-integration-0.7
If you are a Java developer and want to use Mahout and Machine Learning to solve Big Data analytics use-cases then this book is for you. Familiarity with shell-scripts is assumed but no prior ...
mahout-core-0.9.jar+mahout-core-0.8.jar+mahout-core-0.1.jar
Mahout 官方文档,简单介绍Mahout概念及其安装和简单使用
http://blog.csdn.net/u010967382/article/details/25368795#comments 博客配套代码
mahout之taste介绍,给公司同事做报告时准备的ppt,希望有用
Mahout0.8_API 喜欢的人就请下载吧
spring-mahout-demo-----一个简单的spring-mahout结合的例子,是很好的学习开发思路的例子。