2017-01-17 1 views
1

J'utilise étincelle 2.0.0 et je voudrais former un modèle de LDA ensemble de données Tweets, lorsque je tente d'exécuteralgorithme Run LDA sur Spark 2.0

val ldaModel = new LDA().setK(3).run(corpus) 

Je reçois cette erreur

error: reference to LDA is ambiguous; 
it is imported twice in the same scope by import org.apache.spark.ml.clustering.LDA and import org.apache.spark.mllib.clustering.LDA 

Quelqu'un pourrait m'aider s'il vous plaît? Merci!

+0

pouvez-vous s'il vous plaît télécharger le code –

+0

vous avez importé le LDA deux fois voir l'importation, vous trouverez importation org.apache.spark.ml.clustering.LDA importation org.apache.spark.mllib.clustering.LDA –

Répondre

1

On dirait que vous avez à la fois des déclarations d'importation suivantes:

import org.apache.spark.ml.clustering.LDA 
import org.apache.spark.mllib.clustering.LDA 

Vous devez supprimer l'un d'eux.

Si vous utilisez Spark ML (cadre de données API basée), la syntaxe correcte serait:

import org.apache.spark.ml.clustering.LDA 

/*feature extraction step*/ 

val lda = new LDA().setK(3) 
val model = lda.fit(corpus) 

si vous utilisez l'API à base RDD alors vous devez écrire:

import org.apache.spark.mllib.clustering.LDA 

/*feature extraction step*/ 

val lda = new LDA().setK(3) 
val model = lda.run(corpus)