You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by ZakariaHili <gi...@git.apache.org> on 2016/11/21 14:28:57 UTC
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
GitHub user ZakariaHili opened a pull request:
https://github.com/apache/spark/pull/15965
[SPARK-18356] [ML] Improve MLKmeans Performance
## What changes were proposed in this pull request?
Spark Kmeans fit() doesn't cache the RDD which generates a lot of warnings :
WARN KMeans: The input data is not directly cached, which may hurt performance if its parent RDDs are also uncached.
So, Kmeans should cache the internal rdd before calling the Mllib.Kmeans algo, this helped to improve spark kmeans performance by 14%
https://github.com/ZakariaHili/spark/commit/a9cf905cf7dbd50eeb9a8b4f891f2f41ea672472
@hhbyyh
## How was this patch tested?
Pass Kmeans tests and existing tests
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ZakariaHili/spark zakbranch
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/15965.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 #15965
----
commit a9cf905cf7dbd50eeb9a8b4f891f2f41ea672472
Author: Zakaria_Hili <za...@gmail.com>
Date: 2016-11-21T13:36:47Z
improve MLKmeans
commit f83473470b09cc52b3ebdc3f71c381659ff096d0
Author: HILI Zakaria <za...@gmail.com>
Date: 2016-11-21T13:48:22Z
[SPARK-18356] [ML] Improve MLKmeans Performance
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:
https://github.com/apache/spark/pull/15965
Can one of the admins verify this patch?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r89129439
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -304,14 +305,21 @@ class KMeans @Since("1.5.0") (
@Since("1.5.0")
def setSeed(value: Long): this.type = set(seed, value)
- @Since("2.0.0")
+ @Since("2.2.0")
--- End diff --
Why did you change this? this is wrong.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili closed the pull request at:
https://github.com/apache/spark/pull/15965
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:
https://github.com/apache/spark/pull/15965
Can one of the admins verify this patch?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on the issue:
https://github.com/apache/spark/pull/15965
@srowen, Ok I found it
I fixed
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r89078980
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -306,12 +307,19 @@ class KMeans @Since("1.5.0") (
@Since("2.0.0")
override def fit(dataset: Dataset[_]): KMeansModel = {
+ val handlePersistence = dataset.rdd.getStorageLevel == StorageLevel.NONE
+ fit(dataset, handlePersistence)
+ }
+ @Since("2.0.0")
--- End diff --
This still has several problems. This can't be since 2.0.0 and there is no space before this line.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r88912298
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -233,7 +232,10 @@ object KMeansModel extends MLReadable[KMeansModel] {
val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
val dataPath = new Path(path, "data").toString
- val clusterCenters = if (majorVersion(metadata.sparkVersion) >= 2) {
+ val versionRegex = "([0-9]+)\\.(.+)".r
--- End diff --
Hi Sean,
I will change the file, then i will recompile it + tests
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on the issue:
https://github.com/apache/spark/pull/15965
@srowen, I think it's ready to merge
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on the issue:
https://github.com/apache/spark/pull/15965
Hi @jkbradley,
In actually, I thought of the same thing, but Mr. yuhao yang advised me to do the same style of LogisticRegression.scala
anywhere I changed the file as you want, and I changed the code a little (e.g : no need to generate the rdd two time
the first one to check storage level and the second one for Kmeans
)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by hhbyyh <gi...@git.apache.org>.
Github user hhbyyh commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r88950358
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -304,14 +306,26 @@ class KMeans @Since("1.5.0") (
@Since("1.5.0")
def setSeed(value: Long): this.type = set(seed, value)
- @Since("2.0.0")
+ @Since("2.0.0")
override def fit(dataset: Dataset[_]): KMeansModel = {
+ /*
+ Before fit the dataset, we check storage level of the rdd
+ if rdd is not cached, we cached our RDD
+ */
--- End diff --
The comment may not be necessary, as it's used elsewhere and clear by the code itself
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by hhbyyh <gi...@git.apache.org>.
Github user hhbyyh commented on the issue:
https://github.com/apache/spark/pull/15965
@ZakariaHili Great to see your PR. @srowen is right, please try to merge with the latest code.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r89079712
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -321,12 +329,15 @@ class KMeans @Since("1.5.0") (
.setMaxIterations($(maxIter))
.setSeed($(seed))
.setEpsilon($(tol))
- val parentModel = algo.run(rdd, Option(instr))
+ val parentModel = algo.run(instances, Option(instr))
val model = copyValues(new KMeansModel(uid, parentModel).setParent(this))
val summary = new KMeansSummary(
model.transform(dataset), $(predictionCol), $(featuresCol), $(k))
model.setSummary(summary)
instr.logSuccess(model)
+ if (handlePersistence) {
+ instances.unpersist()
--- End diff --
the space is fixed
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on the issue:
https://github.com/apache/spark/pull/15965
Merged to master
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:
https://github.com/apache/spark/pull/15965
Can one of the admins verify this patch?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:
https://github.com/apache/spark/pull/15965
**[Test build #3436 has started](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/3436/consoleFull)** for PR 15965 at commit [`fd4543d`](https://github.com/apache/spark/commit/fd4543d918b26b451000fe92fbe1cdb259a6687b).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r92402189
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -306,12 +307,20 @@ class KMeans @Since("1.5.0") (
@Since("2.0.0")
override def fit(dataset: Dataset[_]): KMeansModel = {
+ val handlePersistence = dataset.rdd.getStorageLevel == StorageLevel.NONE
+ fit(dataset, handlePersistence)
+ }
+
+ @Since("2.2.0")
+ protected def fit(dataset: Dataset[_], handlePersistence: Boolean): KMeansModel = {
--- End diff --
Hi @jkbradley,
In actually, I thought of the same thing, but Mr. yuhao yang advised me to do the same style of LogisticRegression.scala
anywhere I changed the file as you want, and I changed the code a little (e.g : no need to generate the rdd two times
the first one to check storage level and the second one for Kmeans
)
here the change
https://github.com/ZakariaHili/spark/commit/58de5499d0930e4019c94718a2a9ed3dd715acb2
do you still want from me to send a PR ?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r89079016
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -321,12 +329,15 @@ class KMeans @Since("1.5.0") (
.setMaxIterations($(maxIter))
.setSeed($(seed))
.setEpsilon($(tol))
- val parentModel = algo.run(rdd, Option(instr))
+ val parentModel = algo.run(instances, Option(instr))
val model = copyValues(new KMeansModel(uid, parentModel).setParent(this))
val summary = new KMeansSummary(
model.transform(dataset), $(predictionCol), $(featuresCol), $(k))
model.setSummary(summary)
instr.logSuccess(model)
+ if (handlePersistence) {
+ instances.unpersist()
--- End diff --
fix spacing here
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r89108412
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -306,12 +307,18 @@ class KMeans @Since("1.5.0") (
@Since("2.0.0")
override def fit(dataset: Dataset[_]): KMeansModel = {
+ val handlePersistence = dataset.rdd.getStorageLevel == StorageLevel.NONE
+ fit(dataset, handlePersistence)
+ }
+ protected def fit(dataset: Dataset[_], handlePersistence: Boolean): KMeansModel = {
--- End diff --
@srowen ,If I understand, you want something like this :
@ Since("2.2.0")
override def fit(dataset: Dataset[_]): KMeansModel = {
val handlePersistence = dataset.rdd.getStorageLevel == StorageLevel.NONE
fit(dataset, handlePersistence)
}
@ Since("2.2.0")
protected def fit(dataset: Dataset[_], handlePersistence: Boolean): KMeansModel = {
transformSchema(dataset.schema, logging = true)
val instances: RDD[OldVector] = dataset.select(col($(featuresCol))).rdd.map {
case Row(point: Vector) => OldVectors.fromML(point)
}
update since 2.0.0 to 2.2.0 and i have to add a space between those two methods.
is that right ?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
GitHub user ZakariaHili reopened a pull request:
https://github.com/apache/spark/pull/15965
[SPARK-18356] [ML] Improve MLKmeans Performance
## What changes were proposed in this pull request?
Spark Kmeans fit() doesn't cache the RDD which generates a lot of warnings :
WARN KMeans: The input data is not directly cached, which may hurt performance if its parent RDDs are also uncached.
So, Kmeans should cache the internal rdd before calling the Mllib.Kmeans algo, this helped to improve spark kmeans performance by 14%
https://github.com/ZakariaHili/spark/commit/a9cf905cf7dbd50eeb9a8b4f891f2f41ea672472
@hhbyyh
## How was this patch tested?
Pass Kmeans tests and existing tests
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ZakariaHili/spark zakbranch
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/15965.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 #15965
----
commit dd2062dba598862020013941cf78c7d1bbdb5d4b
Author: Zakaria_Hili <za...@gmail.com>
Date: 2016-11-22T09:14:09Z
[SPARK-18356] [ML] Improve MLKmeans Performance
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on the issue:
https://github.com/apache/spark/pull/15965
Sorry, I didn't know that you already accepted some changes from other people, so I had to force the synchronization, then re-test everything.
Now, the code is clean
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili closed the pull request at:
https://github.com/apache/spark/pull/15965
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r89079674
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -306,12 +307,19 @@ class KMeans @Since("1.5.0") (
@Since("2.0.0")
override def fit(dataset: Dataset[_]): KMeansModel = {
+ val handlePersistence = dataset.rdd.getStorageLevel == StorageLevel.NONE
+ fit(dataset, handlePersistence)
+ }
+ @Since("2.0.0")
--- End diff --
Ok it's removed
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by hhbyyh <gi...@git.apache.org>.
Github user hhbyyh commented on the issue:
https://github.com/apache/spark/pull/15965
LGTM.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r88971282
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -33,11 +33,10 @@ import org.apache.spark.rdd.RDD
import org.apache.spark.sql.{DataFrame, Dataset, Row}
import org.apache.spark.sql.functions.{col, udf}
import org.apache.spark.sql.types.{IntegerType, StructType}
-import org.apache.spark.util.VersionUtils.majorVersion
-
+import org.apache.spark.storage.StorageLevel
/**
* Common params for KMeans and KMeansModel
- */
+ */
--- End diff --
I cleaned the code, then I run /dev/lint-scala and I received :
Scalastyle checks passed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:
https://github.com/apache/spark/pull/15965
**[Test build #3438 has finished](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/3438/consoleFull)** for PR 15965 at commit [`f17a54c`](https://github.com/apache/spark/commit/f17a54c34e9aa007f36426c2b8459ab0bf784863).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by hhbyyh <gi...@git.apache.org>.
Github user hhbyyh commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r88949815
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -33,11 +33,10 @@ import org.apache.spark.rdd.RDD
import org.apache.spark.sql.{DataFrame, Dataset, Row}
import org.apache.spark.sql.functions.{col, udf}
import org.apache.spark.sql.types.{IntegerType, StructType}
-import org.apache.spark.util.VersionUtils.majorVersion
-
+import org.apache.spark.storage.StorageLevel
/**
* Common params for KMeans and KMeansModel
- */
+ */
--- End diff --
remove the extra space, please use [Spark root]/dev/lint-scala to verify your code style.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:
https://github.com/apache/spark/pull/15965
**[Test build #3436 has finished](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/3436/consoleFull)** for PR 15965 at commit [`fd4543d`](https://github.com/apache/spark/commit/fd4543d918b26b451000fe92fbe1cdb259a6687b).
* This patch **fails Scala style tests**.
* This patch merges cleanly.
* This patch adds no public classes.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:
https://github.com/apache/spark/pull/15965
**[Test build #3438 has started](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/3438/consoleFull)** for PR 15965 at commit [`f17a54c`](https://github.com/apache/spark/commit/f17a54c34e9aa007f36426c2b8459ab0bf784863).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by hhbyyh <gi...@git.apache.org>.
Github user hhbyyh commented on the issue:
https://github.com/apache/spark/pull/15965
Hi @ZakariaHili is it finished? https://github.com/apache/spark/pull/15965/files still contains a lot of unrelated code change.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/spark/pull/15965
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r89091350
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -306,12 +307,18 @@ class KMeans @Since("1.5.0") (
@Since("2.0.0")
override def fit(dataset: Dataset[_]): KMeansModel = {
+ val handlePersistence = dataset.rdd.getStorageLevel == StorageLevel.NONE
+ fit(dataset, handlePersistence)
+ }
+ protected def fit(dataset: Dataset[_], handlePersistence: Boolean): KMeansModel = {
--- End diff --
Still wrong -- no space, and now no `@Since` at all. This is `@Since("2.2.0")` if it goes in.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r89129561
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -304,14 +305,21 @@ class KMeans @Since("1.5.0") (
@Since("1.5.0")
def setSeed(value: Long): this.type = set(seed, value)
- @Since("2.0.0")
+ @Since("2.2.0")
override def fit(dataset: Dataset[_]): KMeansModel = {
+ val handlePersistence = dataset.rdd.getStorageLevel == StorageLevel.NONE
+ fit(dataset, handlePersistence)
+}
+ @Since("2.2.0")
--- End diff --
There is still no blank line above this line -- not sure how else to express this?
The indentation of the line above is off too.
Look, you should match the style you see around this code, and you can see how it isn't the same? just make it match.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r88904864
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -233,7 +232,10 @@ object KMeansModel extends MLReadable[KMeansModel] {
val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
val dataPath = new Path(path, "data").toString
- val clusterCenters = if (majorVersion(metadata.sparkVersion) >= 2) {
+ val versionRegex = "([0-9]+)\\.(.+)".r
--- End diff --
Your change is reverting some other changes like this one. Can you clean this up to only reflect the changes you intend?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r89120396
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -305,11 +305,12 @@ class KMeans @Since("1.5.0") (
@Since("1.5.0")
def setSeed(value: Long): this.type = set(seed, value)
- @Since("2.0.0")
+ @Since("2.2.0")
override def fit(dataset: Dataset[_]): KMeansModel = {
val handlePersistence = dataset.rdd.getStorageLevel == StorageLevel.NONE
fit(dataset, handlePersistence)
- }
+}
+ @Since("2.2.0")
--- End diff --
@srowen ,now I think I understand what do you mean by no space here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on the issue:
https://github.com/apache/spark/pull/15965
Hi Yuhao , are you sure ?
I think that you still compare previous commits with
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark issue #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on the issue:
https://github.com/apache/spark/pull/15965
I think that's OK. @hhbyyh ?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r89485154
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -310,7 +310,7 @@ class KMeans @Since("1.5.0") (
val handlePersistence = dataset.rdd.getStorageLevel == StorageLevel.NONE
fit(dataset, handlePersistence)
}
-
+
--- End diff --
I didn't see that with vim editor
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
GitHub user ZakariaHili reopened a pull request:
https://github.com/apache/spark/pull/15965
[SPARK-18356] [ML] Improve MLKmeans Performance
## What changes were proposed in this pull request?
Spark Kmeans fit() doesn't cache the RDD which generates a lot of warnings :
WARN KMeans: The input data is not directly cached, which may hurt performance if its parent RDDs are also uncached.
So, Kmeans should cache the internal rdd before calling the Mllib.Kmeans algo, this helped to improve spark kmeans performance by 14%
https://github.com/ZakariaHili/spark/commit/a9cf905cf7dbd50eeb9a8b4f891f2f41ea672472
@hhbyyh
## How was this patch tested?
Pass Kmeans tests and existing tests
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ZakariaHili/spark zakbranch
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/15965.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 #15965
----
commit 6b596dcd6a8fe6a6574e4fdda80fdf424c7d8777
Author: Zakaria_Hili <za...@gmail.com>
Date: 2016-11-22T09:33:11Z
[SPARK-18356] [ML] Improve MLKmeans Performance
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by jkbradley <gi...@git.apache.org>.
Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r92527086
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -306,12 +307,20 @@ class KMeans @Since("1.5.0") (
@Since("2.0.0")
override def fit(dataset: Dataset[_]): KMeansModel = {
+ val handlePersistence = dataset.rdd.getStorageLevel == StorageLevel.NONE
+ fit(dataset, handlePersistence)
+ }
+
+ @Since("2.2.0")
+ protected def fit(dataset: Dataset[_], handlePersistence: Boolean): KMeansModel = {
--- End diff --
I like the change in terms of eliminating the extra fit() method (which is not done anywhere else in spark.ml), but I think you'll need to keep the original test for storage level ```val handlePersistence = dataset.rdd.getStorageLevel == StorageLevel.NONE```. In the current change, the RDD being tested is different from ```dataset.rdd```, so handlePersistence would always be true regardless of the original storage level. Could you please send a little PR which merges the 2 fit() methods? Thanks!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request #15965: [SPARK-18356] [ML] Improve MLKmeans Performance
Posted by ZakariaHili <gi...@git.apache.org>.
Github user ZakariaHili commented on a diff in the pull request:
https://github.com/apache/spark/pull/15965#discussion_r88971520
--- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala ---
@@ -233,7 +232,10 @@ object KMeansModel extends MLReadable[KMeansModel] {
val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
val dataPath = new Path(path, "data").toString
- val clusterCenters = if (majorVersion(metadata.sparkVersion) >= 2) {
+ val versionRegex = "([0-9]+)\\.(.+)".r
--- End diff --
sorry for my late, I was busy,
now , I think the code is ready
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org