Skip to content

Commit 6181937

Browse files
MechCodermengxr
authored andcommitted
[SPARK-7946] [MLLIB] DecayFactor wrongly set in StreamingKMeans
Author: MechCoder <[email protected]> Closes #6497 from MechCoder/spark-7946 and squashes the following commits: 2fdd0a3 [MechCoder] Add non-regression test 8c988c6 [MechCoder] [SPARK-7946] DecayFactor wrongly set in StreamingKMeans
1 parent 4782e13 commit 6181937

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class StreamingKMeans(
178178

179179
/** Set the decay factor directly (for forgetful algorithms). */
180180
def setDecayFactor(a: Double): this.type = {
181-
this.decayFactor = decayFactor
181+
this.decayFactor = a
182182
this
183183
}
184184

mllib/src/test/scala/org/apache/spark/mllib/clustering/StreamingKMeansSuite.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ class StreamingKMeansSuite extends FunSuite with TestSuiteBase {
133133
assert(math.abs(c1) ~== 0.8 absTol 0.6)
134134
}
135135

136+
test("SPARK-7946 setDecayFactor") {
137+
val kMeans = new StreamingKMeans()
138+
assert(kMeans.decayFactor === 1.0)
139+
kMeans.setDecayFactor(2.0)
140+
assert(kMeans.decayFactor === 2.0)
141+
}
142+
136143
def StreamingKMeansDataGenerator(
137144
numPoints: Int,
138145
numBatches: Int,

0 commit comments

Comments
 (0)