Repository: spark
Updated Branches:
refs/heads/master 72a23a6c4 -> dc9b32080
[SPARK-25793][ML] call SaveLoadV2_0.load for classNameV2_0
## What changes were proposed in this pull request?
The following code in BisectingKMeansModel.load calls the wrong version of load.
```
case (SaveLoadV2_0.thisClassName, SaveLoadV2_0.thisFormatVersion) =>
val model = SaveLoadV1_0.load(sc, path)
```
Closes #22790 from huaxingao/spark-25793.
Authored-by: Huaxin Gao <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/dc9b3208
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/dc9b3208
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/dc9b3208
Branch: refs/heads/master
Commit: dc9b320807881403ca9f1e2e6d01de4b52db3975
Parents: 72a23a6
Author: Huaxin Gao <[email protected]>
Authored: Fri Oct 26 11:07:55 2018 +0800
Committer: Wenchen Fan <[email protected]>
Committed: Fri Oct 26 11:07:55 2018 +0800
----------------------------------------------------------------------
.../apache/spark/mllib/clustering/BisectingKMeansModel.scala | 6 +++---
.../apache/spark/mllib/clustering/BisectingKMeansSuite.scala | 3 ++-
2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/dc9b3208/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala
----------------------------------------------------------------------
diff --git
a/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala
b/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala
index 9d115af..4c5794f 100644
---
a/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala
+++
b/mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala
@@ -109,10 +109,10 @@ class BisectingKMeansModel private[clustering] (
@Since("2.0.0")
override def save(sc: SparkContext, path: String): Unit = {
- BisectingKMeansModel.SaveLoadV1_0.save(sc, this, path)
+ BisectingKMeansModel.SaveLoadV2_0.save(sc, this, path)
}
- override protected def formatVersion: String = "1.0"
+ override protected def formatVersion: String = "2.0"
}
@Since("2.0.0")
@@ -126,7 +126,7 @@ object BisectingKMeansModel extends
Loader[BisectingKMeansModel] {
val model = SaveLoadV1_0.load(sc, path)
model
case (SaveLoadV2_0.thisClassName, SaveLoadV2_0.thisFormatVersion) =>
- val model = SaveLoadV1_0.load(sc, path)
+ val model = SaveLoadV2_0.load(sc, path)
model
case _ => throw new Exception(
s"BisectingKMeansModel.load did not recognize model with (className,
format version):" +
http://git-wip-us.apache.org/repos/asf/spark/blob/dc9b3208/mllib/src/test/scala/org/apache/spark/mllib/clustering/BisectingKMeansSuite.scala
----------------------------------------------------------------------
diff --git
a/mllib/src/test/scala/org/apache/spark/mllib/clustering/BisectingKMeansSuite.scala
b/mllib/src/test/scala/org/apache/spark/mllib/clustering/BisectingKMeansSuite.scala
index 35f7932..4a4d8b5 100644
---
a/mllib/src/test/scala/org/apache/spark/mllib/clustering/BisectingKMeansSuite.scala
+++
b/mllib/src/test/scala/org/apache/spark/mllib/clustering/BisectingKMeansSuite.scala
@@ -187,11 +187,12 @@ class BisectingKMeansSuite extends SparkFunSuite with
MLlibTestSparkContext {
val points = (1 until 8).map(i => Vectors.dense(i))
val data = sc.parallelize(points, 2)
- val model = new BisectingKMeans().run(data)
+ val model = new
BisectingKMeans().setDistanceMeasure(DistanceMeasure.COSINE).run(data)
try {
model.save(sc, path)
val sameModel = BisectingKMeansModel.load(sc, path)
assert(model.k === sameModel.k)
+ assert(model.distanceMeasure === sameModel.distanceMeasure)
model.clusterCenters.zip(sameModel.clusterCenters).foreach(c => c._1 ===
c._2)
} finally {
Utils.deleteRecursively(tempDir)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]