You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by mgaido91 <gi...@git.apache.org> on 2018/10/18 10:31:39 UTC

[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

GitHub user mgaido91 opened a pull request:

    https://github.com/apache/spark/pull/22764

    [SPARK-25765][ML] Add training cost to BisectingKMeans summary

    ## What changes were proposed in this pull request?
    
    The PR adds the `trainingCost` value to the `BisectingKMeansSummary`, in order to expose the information retrievable by running `computeCost` on the training dataset. This fills the gap with `KMeans` implementation.
    
    ## How was this patch tested?
    
    improved UTs


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mgaido91/spark SPARK-25765

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/22764.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #22764
    
----
commit 6460fe7288a63ede7c8e66d134d780241951cf9e
Author: Marco Gaido <ma...@...>
Date:   2018-10-18T10:29:35Z

    [SPARK-25765][ML] Add training cost to BisectingKMeans summary

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226801896
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/BisectingKMeans.scala ---
    @@ -310,4 +317,6 @@ class BisectingKMeansSummary private[clustering] (
         predictionCol: String,
         featuresCol: String,
         k: Int,
    -    numIter: Int) extends ClusteringSummary(predictions, predictionCol, featuresCol, k, numIter)
    +    numIter: Int,
    +    @Since("2.4.0") val trainingCost: Double)
    --- End diff --
    
    Since #22756 is reverted, are we going to change the `Since` version for this, too?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    **[Test build #98169 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/98169/testReport)** for PR 22764 at commit [`0c74a09`](https://github.com/apache/spark/commit/0c74a09cbfdd0b130c94c6d631bdc6d957c79d99).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    Merged build finished. Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    Merged build finished. Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    **[Test build #97529 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/97529/testReport)** for PR 22764 at commit [`5919d3c`](https://github.com/apache/spark/commit/5919d3c01da5bc24f287e2efae2ddd006666ab24).


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    **[Test build #97529 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/97529/testReport)** for PR 22764 at commit [`5919d3c`](https://github.com/apache/spark/commit/5919d3c01da5bc24f287e2efae2ddd006666ab24).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    Since this PR is a little more complicated than we expect, we decided to not have it in 2.4.0. I'm not sure if we can treat it as a special case and put it in 2.4.1, cc @mengxr 
    
    Anyway, the other 2 related PRs(deprecating the API and updating the example) are reverted. We need to think about what we should do if we can only do this in 3.0.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226693546
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    The answer is yes, because of versioning:
     - all the versions of Spark released so far, use the versions `"1.0"`, which is loaded/written with the `SaveLoadV1_0` class (see https://github.com/apache/spark/pull/22764/files#diff-458b0e49bfc4a4dd993ea6cb66af4b4dR125);
     - there can't be a model with version `"2.0"` without `trainingCost`, because `SaveLoadV2_0` was introduced in a previous commit which lands only on 2.4 and has not yet been released.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/4573/
    Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/98169/
    Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/97529/
    Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    cc @cloud-fan @dongjoon-hyun @holdenk @srowen


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by WeichenXu123 <gi...@git.apache.org>.
Github user WeichenXu123 commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    I think it can target for 3.0. since 2.4 will be released soon and this PR looks a little complex and need take  some time to check carefully.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/4085/
    Test FAILed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    Merged build finished. Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226652377
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    Do other models have this problem? I was told that this change just follows what we did for other models before.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226358124
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/BisectingKMeans.scala ---
    @@ -310,4 +317,6 @@ class BisectingKMeansSummary private[clustering] (
         predictionCol: String,
         featuresCol: String,
         k: Int,
    -    numIter: Int) extends ClusteringSummary(predictions, predictionCol, featuresCol, k, numIter)
    +    numIter: Int,
    +    @Since("2.4.0") val trainingCost: Double)
    --- End diff --
    
    2.4.0? or 3.0.0?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    @dbtsai any comments on this? thanks.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    @dbtsai any luck with this? Thanks.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    @dbtsai sure, thanks. Sorry for bothering you. Have a nice vacation!


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226668414
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    Thank you all for the comments and sorry for the late answer. Just a couple of notes on your comments @WeichenXu123  (I may be missing something, so please correct me if I am wrong):
    
     - I checked the `ml.clustering.KMeansModel.KMeansModelReader` and it doesn't store anything related to the summary. Summary is not recovered after load of the model, so I don't see any reason why we should modify the read/load of `ml.clustering.BisectingKMeansModel.BisectingKMeansModelReader`;
     - this model can read from previous versions, since this is version "2.0", which was introduced for Spark 2.4; for previous versions, we read/write version "1.0"; the version check method for versioning is used only for the `ml` package, not in `mllib` where we have this versioning approach;
    
    > I was told that this change just follows what we did for other models before.
    
    @cloud-fan Yes, let me link the PR for KMeans doing the same, which is: https://github.com/apache/spark/pull/20629.
    
    Just a final comment which I hope clarifies which is the source of the confusion here and the reason of the above comments by @viirya and @WeichenXu123: `trainingCost` here is a member of the `summary`, not a parameter of the model for the `ml.clustering.BisectingKMeansModel`. Instead, it is a member of the model for `mllib.clustering.BisectingKMeansModel` (we have no summary notion there...). So storing it for `mllib` is needed in order for the model read after persisting it being the same of the original one (I think it doesn't pass UTs otherwise). Storing it for the `ml`, instead, it is not needed, because the summary is not persisted. If we want to persist also the summary for `ml` package I think we should best create a separate JIRA and PR for it.
    
    Hope this clarifies (sorry for being so verbose).


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    Merged build finished. Test FAILed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    **[Test build #98169 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/98169/testReport)** for PR 22764 at commit [`0c74a09`](https://github.com/apache/spark/commit/0c74a09cbfdd0b130c94c6d631bdc6d957c79d99).


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226835456
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    @WeichenXu123 I have explained it in  and  https://github.com/apache/spark/pull/22764#discussion_r226693546. If you don't agree or believe on what I said you can try it.
    
    A model saved in 2.3.1 will have "1.0" as version. So this code is not run. Every model from 2.4.0 on, will be saved with "2.0" as version, so it will have this stored. As mentioned, please notice that `SaveLoadV2_0` was introduced for 2.4.0. Of course, if this commit won't go in 2.4, then I'll have to create a `SaveLoadV3_0` in order to support it (or, if we agree that this doesn't need to be restored after model persistence, we can just ignore it).
    
    Hope this clarifies. Thanks.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226688846
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    > this model can read from previous versions, since this is version "2.0", which was introduced for Spark 2.4; for previous versions, we read/write version "1.0"; the version check method for versioning is used only for the ml package, not in mllib where we have this versioning approach;
    
    I meant that can it read old model from previous versions, not that this model can read from previous versions.
    
    In other words, when reading a previous model without "trainingCost" in metadata, can this line work well?
    
    ```scala
    val trainingCost = (metadata \ "trainingCost").extract[Double]
    ```


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226372701
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/BisectingKMeans.scala ---
    @@ -310,4 +317,6 @@ class BisectingKMeansSummary private[clustering] (
         predictionCol: String,
         featuresCol: String,
         k: Int,
    -    numIter: Int) extends ClusteringSummary(predictions, predictionCol, featuresCol, k, numIter)
    +    numIter: Int,
    +    @Since("2.4.0") val trainingCost: Double)
    --- End diff --
    
    this PR targets to 2.4, see more context at https://github.com/apache/spark/pull/22756


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by WeichenXu123 <gi...@git.apache.org>.
Github user WeichenXu123 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r228527916
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    OK. After https://github.com/apache/spark/pull/22790 merged, I think this PR can work.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/4086/
    Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226387346
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/BisectingKMeans.scala ---
    @@ -310,4 +317,6 @@ class BisectingKMeansSummary private[clustering] (
         predictionCol: String,
         featuresCol: String,
         k: Int,
    -    numIter: Int) extends ClusteringSummary(predictions, predictionCol, featuresCol, k, numIter)
    +    numIter: Int,
    +    @Since("2.4.0") val trainingCost: Double)
    --- End diff --
    
    I wouldn't consider this as mandatory. I think what is mandatory to target for 2.4 is to deprecate the `computeCost` method. But I think it is a nice to have, since it is a non-deprecated way users have to access this information. In the PR related to `KMeans`, there was quite a discussion about it and it was considered to be part of the deprecation change.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    For KMeans we used the ClusteringEvaluator in the examples. Actually, the training cost is not a good way to evaluate a dataset (the evaluation should be done on a dataset different from the training one).
    
    Maybe we can also add this API in the example to show that it exists, but I have seen no example with a summary shown so...


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226807614
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    Ok. I see. `SaveLoadV2_0` is confused term as I think it is for reading models since Spark 2.0.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    does the example need to be updated with this new API?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    Merged build finished. Test PASSed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226384584
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/BisectingKMeans.scala ---
    @@ -310,4 +317,6 @@ class BisectingKMeansSummary private[clustering] (
         predictionCol: String,
         featuresCol: String,
         k: Int,
    -    numIter: Int) extends ClusteringSummary(predictions, predictionCol, featuresCol, k, numIter)
    +    numIter: Int,
    +    @Since("2.4.0") val trainingCost: Double)
    --- End diff --
    
    oh wait. If the final goal is to have a consistent ML API in 3.0, do we have to put this new API in 2.4?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    as @WeichenXu123 mentioned in https://github.com/apache/spark/pull/22764#discussion_r228527916, I don't see other problems with the current PR. The only thing is: do we want to target it for 2.4 or for 3.0? If the latter, I'll update the PR with the proper deprecation messages. Thanks.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226512051
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/BisectingKMeans.scala ---
    @@ -310,4 +317,6 @@ class BisectingKMeansSummary private[clustering] (
         predictionCol: String,
         featuresCol: String,
         k: Int,
    -    numIter: Int) extends ClusteringSummary(predictions, predictionCol, featuresCol, k, numIter)
    +    numIter: Int,
    +    @Since("2.4.0") val trainingCost: Double)
    --- End diff --
    
    SGTM


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by WeichenXu123 <gi...@git.apache.org>.
Github user WeichenXu123 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226812121
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    @mgaido91 
    What about this way ?
    In `ml` reader, we can load `trainingCost` and then construct `mllib.clustering.BisectingKMeansModel` and pass the `trainingCost` argument and then construct `ml.clustering.BisectingKMeansModel` to wrap that `mllib` model.
    ** Then in `ml` reader we can check the spark major/minor version to keep backwards compatibility, this is a more important thing. **
    ** In `mllib` loader we can ignore loading `trainingCost`, because `mllib` is deprecate, we can ignore adding new features, but we cannot breaking backwards compatibility (your change breaking backwards compatibility). **


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    kindly ping @dbtsai 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226516200
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/BisectingKMeans.scala ---
    @@ -310,4 +317,6 @@ class BisectingKMeansSummary private[clustering] (
         predictionCol: String,
         featuresCol: String,
         k: Int,
    -    numIter: Int) extends ClusteringSummary(predictions, predictionCol, featuresCol, k, numIter)
    +    numIter: Int,
    +    @Since("2.4.0") val trainingCost: Double)
    --- End diff --
    
    Ok. I see. Then looks like it is nice to have this in 2.4.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by dbtsai <gi...@git.apache.org>.
Github user dbtsai commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    @mgaido91 I'm on thanksgiving vacation, will be back to community to help code review on Nov 21st. Sorry for the delay.  


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226820605
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    @WeichenXu123 I don't see (and think) this change breaks backwards compatibility for `mllib`. You can still load a model stored by previous versions, the only difference is that it won't have a valid `trainingCost` (but this just means we lack a new feature, all operations/data available before is still there, so backward compatibility is ensured). The same approach was used also for `KMeans`, so if we want to change approach here, we might have to do it also for `KMeans`.
    
    Anyway, regarding your suggestion, since the summary is not recomputed, there is no need at all to store this for `ml`: a loaded model doesn't contain the summary, so doesn't contain the `trainingCost` (same for `KMeans`). We could/should rather ignore at all storing the value, it changes nothing on `ml` side.
    
    On the other side, if we want it to be stored and re-loaded on `ml` side, we should start persisting the summary too there, but as I mentioned before, I think this is a different and bigger change, which should involve all the summary/models and not only `BisectingKMeans`.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    cc @dbtsai 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226516595
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    hmm, can this read old model from previous version?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r228173911
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    yes @WeichenXu123 , you're right, that line is a bug. Thanks for noticing it. Anyway, that is going to be addressed in another PR and it is not (strictly) related to this one. The other option, as I mentioned, is that if we agree that this doesn't need to be restored after model persistence, we can just ignore it in save/load.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by WeichenXu123 <gi...@git.apache.org>.
Github user WeichenXu123 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226826701
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    @mgaido91 
    (I haven't test this, so correct me if I am wrong).
    > I don't see (and think) this change breaks backwards compatibility for mllib.
    
    I am suspicious of this line:
    ```
    val trainingCost = (metadata \ "trainingCost").extract[Double]
    ```
    When loading an old version spark saved `BisectingKMeansModel`, because it do not contain "trainingCost" info, I guess this line will throw error. (Otherwise what will it return ?)



---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    any more comments on this? Thanks


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #22764: [SPARK-25765][ML] Add training cost to BisectingK...

Posted by WeichenXu123 <gi...@git.apache.org>.
Github user WeichenXu123 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22764#discussion_r226520698
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/BisectingKMeansModel.scala ---
    @@ -225,13 +227,14 @@ object BisectingKMeansModel extends Loader[BisectingKMeansModel] {
           assert(formatVersion == thisFormatVersion)
           val rootId = (metadata \ "rootId").extract[Int]
           val distanceMeasure = (metadata \ "distanceMeasure").extract[String]
    +      val trainingCost = (metadata \ "trainingCost").extract[Double]
    --- End diff --
    
    - Could you avoid modifying loading model code in "mllib" package, but modifying code in "ml" package, i.e., the class `ml.clustering.BisectingKMeansModel.BisectingKMeansModelReader`, you can reference the `KMeans` code: `ml.clustering.KMeansModel.KMeansModelReader`.
    
    - And, +1 with @viirya mentioned, we should keep model loading compatibility, add a version check (when >= 2.4) then we load "training cost" . Note that add these in `ml.clustering.BisectingKMeansModel.BisectingKMeansModelReader`.
    
    - And, could you also add version check (when >= 2.4) then we load "training cost" into `ml.clustering.KMeansModel.KMeansModelReader` ? 



---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #22764: [SPARK-25765][ML] Add training cost to BisectingKMeans s...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/22764
  
    thanks @WeichenXu123 , I updated this PR in order to target 3.0.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org