Pyspark - 加载训练有素的模型 word2vec
Pyspark - Load trained model word2vec
我想使用 word2vec 和 PySpark 来处理一些数据。
我之前在 Python.
中使用 Google 训练模型 GoogleNews-vectors-negative300.bin
和 gensim
有没有办法用 mllib.word2vec
加载这个 bin 文件?
或者将数据从 Python {word : [vector]}
(或 .csv
文件)导出为字典然后加载到 PySpark
是否有意义?
谢谢
Binary import is supported in Spark 3.x:
spark.read.format("binaryFile").option("pathGlobFilter", "*.png").load("/path/to/data")
但是,这需要处理二进制数据。因此更推荐 gensim
export:
# Save gensim model
filename = "stored_model.csv"
trained_model.save(filename)
然后 load the model 在 pyspark 中:
df = spark.read.load("stored_model.csv",
format="csv",
sep=";",
inferSchema="true",
header="true")
我想使用 word2vec 和 PySpark 来处理一些数据。 我之前在 Python.
中使用 Google 训练模型GoogleNews-vectors-negative300.bin
和 gensim
有没有办法用 mllib.word2vec
加载这个 bin 文件?
或者将数据从 Python {word : [vector]}
(或 .csv
文件)导出为字典然后加载到 PySpark
是否有意义?
谢谢
Binary import is supported in Spark 3.x:
spark.read.format("binaryFile").option("pathGlobFilter", "*.png").load("/path/to/data")
但是,这需要处理二进制数据。因此更推荐 gensim
export:
# Save gensim model
filename = "stored_model.csv"
trained_model.save(filename)
然后 load the model 在 pyspark 中:
df = spark.read.load("stored_model.csv",
format="csv",
sep=";",
inferSchema="true",
header="true")