[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:
parent
4782e13040
commit
6181937f31
|
@ -178,7 +178,7 @@ class StreamingKMeans(
|
||||||
|
|
||||||
/** Set the decay factor directly (for forgetful algorithms). */
|
/** Set the decay factor directly (for forgetful algorithms). */
|
||||||
def setDecayFactor(a: Double): this.type = {
|
def setDecayFactor(a: Double): this.type = {
|
||||||
this.decayFactor = decayFactor
|
this.decayFactor = a
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,13 @@ class StreamingKMeansSuite extends FunSuite with TestSuiteBase {
|
||||||
assert(math.abs(c1) ~== 0.8 absTol 0.6)
|
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(
|
def StreamingKMeansDataGenerator(
|
||||||
numPoints: Int,
|
numPoints: Int,
|
||||||
numBatches: Int,
|
numBatches: Int,
|
||||||
|
|
Loading…
Reference in a new issue