In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Spark LDA instance
First, prepare data
The data format is: documents: RDD [(Long, Vector)], where: Long is the word vector after the article is segmented by ID,Vector.
It can be converted to RDD [(Long, Vector)] through word segmentation and data format conversion.
Second, establish a model
Import org.apache.spark.mllib.clustering._val ldaOptimizer = new OnlineLDAOptimizer (). SetOptimizeDocConcentration (true) val lda = new LDA () lda.setK (params.k) .setMaxIterations (params.maxIterations). SetDocConcentration (params.docConcentration) .setTopicConcentration (params.topicConcentration) .setOptimizer (ldaOptimizer) .setCheckpointInterval (10) .setSeed (1234) val modelLDA: LDAModel = lda.run (corpus) modelLDA.save (sc.sparkContext, params.modelPath)
Third, model parameters
Case class NewsParams (k: Int = 100, maxIterations: Int = 100, docConcentration: Double =-1, topicConcentration: Double =-1, stopWordFile: String = "zh_stopwords.txt", modelPath: String = "LDAModel.14.100", ldaJsonPath:String = "ldaModel.14.200.json", vocabPath: String = "vocab_info")
IV. Result output
TopicsMatrix and topics (word,topic)) output. Lda on mllib is not distributed. Currently, only topic information is stored, not doc information. If you can only use lda in ml or use the following code to get it.
Val ldaModel = lda.run (documents) val distLDAModel = ldaModel.asInstanceOf [DistributedLDAModel] distLDAModel.topicDistributions
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.