[GitHub] spark pull request #20719: [SPARK-23568][ML] Use metadata numAttributes if a...
Github user asfgit closed the pull request at: https://github.com/apache/spark/pull/20719 --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #20719: [SPARK-23568][ML] Use metadata numAttributes if a...
Github user viirya commented on a diff in the pull request: https://github.com/apache/spark/pull/20719#discussion_r175321399 --- Diff: mllib/src/main/scala/org/apache/spark/ml/evaluation/ClusteringEvaluator.scala --- @@ -170,6 +171,13 @@ private[evaluation] abstract class Silhouette { def overallScore(df: DataFrame, scoreColumn: Column): Double = { df.select(avg(scoreColumn)).collect()(0).getDouble(0) } + + protected def getNumberOfFeatures(dataFrame: DataFrame, columnName: String): Int = { +val group = AttributeGroup.fromStructField(dataFrame.schema(columnName)) +group.numAttributes.getOrElse { --- End diff -- We should use `size` of `AttributeGroup` to determine its number of attributes. When it is -1, we can leverage `first` then. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #20719: [SPARK-23568][ML] Use metadata numAttributes if a...
GitHub user mgaido91 opened a pull request: https://github.com/apache/spark/pull/20719 [SPARK-23568][ML] Use metadata numAttributes if available in Silhouette ## What changes were proposed in this pull request? Silhouette need to know the number of features. This was taken using `first` and checking the size of the vector. Despite this works fine, if the number of attributes is present in metadata, we can avoid to trigger a job for this and use the metadata value. This can help improving performances of course. ## How was this patch tested? existing UTs You can merge this pull request into a Git repository by running: $ git pull https://github.com/mgaido91/spark SPARK-23568 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/20719.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 #20719 commit 73db3b93973b2fa01eb2a34235ff44302f6feaa2 Author: Marco Gaido Date: 2018-03-02T17:10:32Z [SPARK-23568][ML] Use metadata numAttributes if available in Silhouette --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org