Skip to content

Commit 54cf8da

Browse files
committed
some style change
1 parent 68c2318 commit 54cf8da

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

mllib/src/main/scala/org/apache/spark/mllib/clustering/LDAOptimizer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class OnlineLDAOptimizer extends LDAOptimizer {
295295
}
296296

297297
/**
298-
* The function is for test only now. In the future, it can help support training strop/resume
298+
* The function is for test only now. In the future, it can help support training stop/resume
299299
*/
300300
private[clustering] def setLambda(lambda: BDM[Double]): this.type = {
301301
this.lambda = lambda
@@ -310,8 +310,9 @@ class OnlineLDAOptimizer extends LDAOptimizer {
310310
this
311311
}
312312

313-
override private[clustering] def initialize(docs: RDD[(Long, Vector)], lda: LDA):
314-
OnlineLDAOptimizer = {
313+
override private[clustering] def initialize(
314+
docs: RDD[(Long, Vector)],
315+
lda: LDA): OnlineLDAOptimizer = {
315316
this.k = lda.getK
316317
this.corpusSize = docs.count()
317318
this.vocabSize = docs.first()._2.size
@@ -333,7 +334,6 @@ class OnlineLDAOptimizer extends LDAOptimizer {
333334
submitMiniBatch(batch)
334335
}
335336

336-
337337
/**
338338
* Submit a subset (like 1%, decide by the miniBatchFraction) of the corpus to the Online LDA
339339
* model, and it will update the topic distribution adaptively for the terms appearing in the

mllib/src/test/java/org/apache/spark/mllib/clustering/JavaLDASuite.java

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -109,35 +109,38 @@ public void distributedLDAModel() {
109109
assert(model.logPrior() < 0.0);
110110
}
111111

112-
113112
@Test
114113
public void OnlineOptimizerCompatibility() {
115-
int k = 3;
116-
double topicSmoothing = 1.2;
117-
double termSmoothing = 1.2;
118-
119-
// Train a model
120-
OnlineLDAOptimizer op = new OnlineLDAOptimizer().setTau_0(1024).setKappa(0.51)
121-
.setGammaShape(1e40).setMiniBatchFraction(0.5);
122-
LDA lda = new LDA();
123-
lda.setK(k)
124-
.setDocConcentration(topicSmoothing)
125-
.setTopicConcentration(termSmoothing)
126-
.setMaxIterations(5)
127-
.setSeed(12345)
128-
.setOptimizer(op);
129-
130-
LDAModel model = lda.run(corpus);
131-
132-
// Check: basic parameters
133-
assertEquals(model.k(), k);
134-
assertEquals(model.vocabSize(), tinyVocabSize);
135-
136-
// Check: topic summaries
137-
Tuple2<int[], double[]>[] roundedTopicSummary = model.describeTopics();
138-
assertEquals(roundedTopicSummary.length, k);
139-
Tuple2<int[], double[]>[] roundedLocalTopicSummary = model.describeTopics();
140-
assertEquals(roundedLocalTopicSummary.length, k);
114+
int k = 3;
115+
double topicSmoothing = 1.2;
116+
double termSmoothing = 1.2;
117+
118+
// Train a model
119+
OnlineLDAOptimizer op = new OnlineLDAOptimizer()
120+
.setTau_0(1024)
121+
.setKappa(0.51)
122+
.setGammaShape(1e40)
123+
.setMiniBatchFraction(0.5);
124+
125+
LDA lda = new LDA();
126+
lda.setK(k)
127+
.setDocConcentration(topicSmoothing)
128+
.setTopicConcentration(termSmoothing)
129+
.setMaxIterations(5)
130+
.setSeed(12345)
131+
.setOptimizer(op);
132+
133+
LDAModel model = lda.run(corpus);
134+
135+
// Check: basic parameters
136+
assertEquals(model.k(), k);
137+
assertEquals(model.vocabSize(), tinyVocabSize);
138+
139+
// Check: topic summaries
140+
Tuple2<int[], double[]>[] roundedTopicSummary = model.describeTopics();
141+
assertEquals(roundedTopicSummary.length, k);
142+
Tuple2<int[], double[]>[] roundedLocalTopicSummary = model.describeTopics();
143+
assertEquals(roundedLocalTopicSummary.length, k);
141144
}
142145

143146
private static int tinyK = LDASuite$.MODULE$.tinyK();

0 commit comments

Comments
 (0)