[SPARK-7946] [MLLIB] DecayFactor wrongly set in StreamingKMeans

Author: MechCoder <manojkumarsivaraj334@gmail.com>

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
This commit is contained in:
MechCoder 2015-05-29 11:36:41 -07:00 committed by Xiangrui Meng
parent 4782e13040
commit 6181937f31
2 changed files with 8 additions and 1 deletions

View file

@ -178,7 +178,7 @@ class StreamingKMeans(
/** Set the decay factor directly (for forgetful algorithms). */
def setDecayFactor(a: Double): this.type = {
this.decayFactor = decayFactor
this.decayFactor = a
this
}

View file

@ -133,6 +133,13 @@ class StreamingKMeansSuite extends FunSuite with TestSuiteBase {
assert(math.abs(c1) ~== 0.8 absTol 0.6)
}
test("SPARK-7946 setDecayFactor") {
val kMeans = new StreamingKMeans()
assert(kMeans.decayFactor === 1.0)
kMeans.setDecayFactor(2.0)
assert(kMeans.decayFactor === 2.0)
}
def StreamingKMeansDataGenerator(
numPoints: Int,
numBatches: Int,