【发布时间】:2018-06-13 15:36:00
【问题描述】:
我正在尝试使用 Spark 的 MLLib 实现词向量化。我正在按照here 给出的示例进行操作。
我有一堆句子,我想作为输入来训练模型。但是我不确定这个模型是接受句子还是只是把所有的词都当作一个字符串序列。
我的输入如下:
scala> v.take(5)
res31: Array[Seq[String]] = Array(List([WrappedArray(0_42)]), List([WrappedArray(big, baller, shoe, ?)]), List([WrappedArray(since, eliud, win, ,, quick, fact, from, runner, from, country, kalenjins, !, write, ., happy, quick, fact, kalenjins, location, :, kenya, (, kenya's, western, highland, rift, valley, ), population, :, 4, ., 9, million, ;, compose, 11, subtribes, language, :, kalenjin, ;, swahili, ;, english, church, :, christianity, ~, africa, inland, church, [, aic, ],, church, province, kenya, [, cpk, ],, roman, catholic, church, ;, islam, translation, :, kalenjin, translate, ", tell, ", formation, :, wwii, ,, gikuyu, tribal, member, wish, separate, create, identity, ., later, ,, student, attend, alliance, high, school, (, first, british, public, school, kenya, ), form, ...
但是当我尝试在这个输入上训练我的 word2vec 模型时它不起作用。
scala> val word2vec = new Word2Vec()
word2vec: org.apache.spark.mllib.feature.Word2Vec = org.apache.spark.mllib.feature.Word2Vec@51567040
scala> val model = word2vec.fit(v)
java.lang.IllegalArgumentException: requirement failed: The vocabulary size should be > 0. You may need to check the setting of minCount, which could be large enough to remove all your words in sentences.
Word2Vec不接受句子作为输入吗?
【问题讨论】:
标签: scala apache-spark machine-learning apache-spark-mllib word2vec