Skip to content

Commit aefb113

Browse files
MechCodermengxr
authored andcommitted
[SPARK-7946] [MLLIB] DecayFactor wrongly set in StreamingKMeans
Author: MechCoder <manojkumarsivaraj334@gmail.com> Closes apache#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 (cherry picked from commit 6181937) Signed-off-by: Xiangrui Meng <meng@databricks.com>
1 parent c0a0eaa commit aefb113

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
@@ -174,7 +174,7 @@ class StreamingKMeans(
174174

175175
/** Set the decay factor directly (for forgetful algorithms). */
176176
def setDecayFactor(a: Double): this.type = {
177-
this.decayFactor = decayFactor
177+
this.decayFactor = a
178178
this
179179
}
180180

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)