Uh oh!
There was an error while loading. Please reload this page.
[WIP] [SPARK-1328] Add vector statistics - #268
Conversation
AmplabJenkins
commented
Mar 29, 2014
Merged build triggered. Build is starting -or- tests failed to complete. |
AmplabJenkins
commented
Mar 29, 2014
Merged build started. Build is starting -or- tests failed to complete. |
AmplabJenkins
commented
Mar 29, 2014
Merged build finished. All automated tests passed. |
AmplabJenkins
commented
Mar 29, 2014
All automated tests passed. |
mengxr
commented
Mar 29, 2014
@yinxusen Thanks for working on this! I don't think row statistics are important because they represent values for different features. For column statistics, instead of implementing each statistic separately, we can compute all common statistics like (n, nnz, mean, variance, max, min) in a single job. This adds little overhead to the computation. Btw, |
yinxusen
commented
Mar 30, 2014
AmplabJenkins
commented
Mar 30, 2014
Build triggered. Build is starting -or- tests failed to complete. |
AmplabJenkins
commented
Mar 30, 2014
Build started. Build is starting -or- tests failed to complete. |
yinxusen
commented
Mar 30, 2014
I remove all APIs and reserve a new one call Row-wise statistical quantities are removed because they are meaningless. Column-wise shrinkage and row-wise shrinkage are also removed, because they belong to feature/data selection. We should re-consider them and write in other semantic class such as |
AmplabJenkins
commented
Mar 30, 2014
Build finished. All automated tests passed. |
AmplabJenkins
commented
Mar 30, 2014
All automated tests passed. |
There was a problem hiding this comment.
Please wrap the return type to a class called VectorRDDStatisticalSummary that provides mean, variance, count: Long, min, max, and std. So later we can add more summary statistics to it. I would also recommend changing the method name to summarize or summarizeStatistics.
mengxr
commented
Mar 30, 2014
@yinxusen I want to see whether we can improve the performance. First of all, the complexity should be To apply the formula for mean/variance, you need to do the update at the second row. This is actually not necessary because the summary statistics are invariant to the ordering. Imagine we have this column re-arranged: which still have the same summary statistics. We can skip all zeros and do mean/variance updates based on the non-zero count instead of global count. After I'm okay if you don't have enough time to make the change in this PR. Put a TODO and we can fix it later. |
yinxusen
commented
Mar 31, 2014
@mengxr I am not very sure of the concept of sparse vector. In your example, do you mean the column is If it is the case 1, then it is easy to rewrite it in O(nnz), otherwise, it will be difficult, because we cannot judge whether a column is sparse or not before we count the nnz. If the case 1 is your mean, then I think I should treat sparse vector different with the dense one with the following code:
|
mengxr
commented
Mar 31, 2014
@yinxusen I mean a column. You don't need to check the type as you already use |
yinxusen
commented
Apr 1, 2014
@mengxr Ah... I totally understand your mean. Code is on the way. |
AmplabJenkins
commented
Apr 1, 2014
Build triggered. |
AmplabJenkins
commented
Apr 1, 2014
Build started. |
AmplabJenkins
commented
Apr 1, 2014
Build finished. |
AmplabJenkins
commented
Apr 1, 2014
Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/13630/ |
There was a problem hiding this comment.
Build failed might be caught by this empty line in the end. I'll fix it in next commit with other problems.
AmplabJenkins
commented
Apr 10, 2014
Merged build triggered. |
AmplabJenkins
commented
Apr 10, 2014
Merged build started. |
AmplabJenkins
commented
Apr 10, 2014
Merged build finished. All automated tests passed. |
AmplabJenkins
commented
Apr 10, 2014
All automated tests passed. |
yinxusen
commented
Apr 11, 2014
Conflict in MLUtils and RowMatrix. I think it is OK now.
|
pwendell
commented
Apr 12, 2014
Thanks, merged! |
As with the new vector system in MLlib, we find that it is good to add some new APIs to precess the `RDD[Vector]`. Beside, the former implementation of `computeStat` is not stable which could loss precision, and has the possibility to cause `Nan` in scientific computing, just as said in the [SPARK-1328](https://spark-project.atlassian.net/browse/SPARK-1328). APIs contain: * rowMeans(): RDD[Double] * rowNorm2(): RDD[Double] * rowSDs(): RDD[Double] * colMeans(): Vector * colMeans(size: Int): Vector * colNorm2(): Vector * colNorm2(size: Int): Vector * colSDs(): Vector * colSDs(size: Int): Vector * maxOption((Vector, Vector) => Boolean): Option[Vector] * minOption((Vector, Vector) => Boolean): Option[Vector] * rowShrink(): RDD[Vector] * colShrink(): RDD[Vector] This is working in process now, and some more APIs will add to `LabeledPoint`. Moreover, the implicit declaration will move from `MLUtils` to `MLContext` later. Author: Xusen Yin <yinxusen@gmail.com> Author: Xiangrui Meng <meng@databricks.com> Closes#268 from yinxusen/vector-statistics and squashes the following commits: d61363f [Xusen Yin] rebase to latest master 16ae684 [Xusen Yin] fix minor error and remove useless method 10cf5d3 [Xusen Yin] refine some return type b064714 [Xusen Yin] remove computeStat in MLUtils cbbefdb [Xiangrui Meng] update multivariate statistical summary interface and clean tests 4eaf28a [Xusen Yin] merge VectorRDDStatistics into RowMatrix 48ee053 [Xusen Yin] fix minor error e624f93 [Xusen Yin] fix scala style error 1fba230 [Xusen Yin] merge while loop together 69e1f37 [Xusen Yin] remove lazy eval, and minor memory footprint 548e9de [Xusen Yin] minor revision 86522c4 [Xusen Yin] add comments on functions dc77e38 [Xusen Yin] test sparse vector RDD 18cf072 [Xusen Yin] change def to lazy val to make sure that the computations in function be evaluated only once f7a3ca2 [Xusen Yin] fix the corner case of maxmin 967d041 [Xusen Yin] full revision with Aggregator class 138300c [Xusen Yin] add new Aggregator class 1376ff4 [Xusen Yin] rename variables and adjust code 4a5c38d [Xusen Yin] add scala doc, refine code and comments 036b7a5 [Xusen Yin] fix the bug of Nan occur f6e8e9a [Xusen Yin] add sparse vectors test 4cfbadf [Xusen Yin] fix bug of min max 4e4fbd1 [Xusen Yin] separate seqop and combop out as independent functions a6d5a2e [Xusen Yin] rewrite for only computing non-zero elements 3980287 [Xusen Yin] rename variables 62a2c3e [Xusen Yin] use axpy and in-place if possible 9a75ebd [Xusen Yin] add case class to wrap return values d816ac7 [Xusen Yin] remove useless APIs c4651bb [Xusen Yin] remove row-wise APIs and refine code 1338ea1 [Xusen Yin] all-in-one version test passed cc65810 [Xusen Yin] add parallel mean and variance 9af2e95 [Xusen Yin] refine the code style ad6c82d [Xusen Yin] add shrink test e09d5d2 [Xusen Yin] add scala docs and refine shrink method 8ef3377 [Xusen Yin] pass all tests 28cf060 [Xusen Yin] fix error of column means 54b19ab [Xusen Yin] add new API to shrink RDD[Vector] 8c6c0e1 [Xusen Yin] add basic statistics
As with the new vector system in MLlib, we find that it is good to add some new APIs to precess the `RDD[Vector]`. Beside, the former implementation of `computeStat` is not stable which could loss precision, and has the possibility to cause `Nan` in scientific computing, just as said in the [SPARK-1328](https://spark-project.atlassian.net/browse/SPARK-1328). APIs contain: * rowMeans(): RDD[Double] * rowNorm2(): RDD[Double] * rowSDs(): RDD[Double] * colMeans(): Vector * colMeans(size: Int): Vector * colNorm2(): Vector * colNorm2(size: Int): Vector * colSDs(): Vector * colSDs(size: Int): Vector * maxOption((Vector, Vector) => Boolean): Option[Vector] * minOption((Vector, Vector) => Boolean): Option[Vector] * rowShrink(): RDD[Vector] * colShrink(): RDD[Vector] This is working in process now, and some more APIs will add to `LabeledPoint`. Moreover, the implicit declaration will move from `MLUtils` to `MLContext` later. Author: Xusen Yin <yinxusen@gmail.com> Author: Xiangrui Meng <meng@databricks.com> Closesapache#268 from yinxusen/vector-statistics and squashes the following commits: d61363f [Xusen Yin] rebase to latest master 16ae684 [Xusen Yin] fix minor error and remove useless method 10cf5d3 [Xusen Yin] refine some return type b064714 [Xusen Yin] remove computeStat in MLUtils cbbefdb [Xiangrui Meng] update multivariate statistical summary interface and clean tests 4eaf28a [Xusen Yin] merge VectorRDDStatistics into RowMatrix 48ee053 [Xusen Yin] fix minor error e624f93 [Xusen Yin] fix scala style error 1fba230 [Xusen Yin] merge while loop together 69e1f37 [Xusen Yin] remove lazy eval, and minor memory footprint 548e9de [Xusen Yin] minor revision 86522c4 [Xusen Yin] add comments on functions dc77e38 [Xusen Yin] test sparse vector RDD 18cf072 [Xusen Yin] change def to lazy val to make sure that the computations in function be evaluated only once f7a3ca2 [Xusen Yin] fix the corner case of maxmin 967d041 [Xusen Yin] full revision with Aggregator class 138300c [Xusen Yin] add new Aggregator class 1376ff4 [Xusen Yin] rename variables and adjust code 4a5c38d [Xusen Yin] add scala doc, refine code and comments 036b7a5 [Xusen Yin] fix the bug of Nan occur f6e8e9a [Xusen Yin] add sparse vectors test 4cfbadf [Xusen Yin] fix bug of min max 4e4fbd1 [Xusen Yin] separate seqop and combop out as independent functions a6d5a2e [Xusen Yin] rewrite for only computing non-zero elements 3980287 [Xusen Yin] rename variables 62a2c3e [Xusen Yin] use axpy and in-place if possible 9a75ebd [Xusen Yin] add case class to wrap return values d816ac7 [Xusen Yin] remove useless APIs c4651bb [Xusen Yin] remove row-wise APIs and refine code 1338ea1 [Xusen Yin] all-in-one version test passed cc65810 [Xusen Yin] add parallel mean and variance 9af2e95 [Xusen Yin] refine the code style ad6c82d [Xusen Yin] add shrink test e09d5d2 [Xusen Yin] add scala docs and refine shrink method 8ef3377 [Xusen Yin] pass all tests 28cf060 [Xusen Yin] fix error of column means 54b19ab [Xusen Yin] add new API to shrink RDD[Vector] 8c6c0e1 [Xusen Yin] add basic statistics
As with the new vector system in MLlib, we find that it is good to add some new APIs to precess the
RDD[Vector]. Beside, the former implementation ofcomputeStatis not stable which could loss precision, and has the possibility to causeNanin scientific computing, just as said in the SPARK-1328.APIs contain:
This is working in process now, and some more APIs will add to
LabeledPoint. Moreover, the implicit declaration will move fromMLUtilstoMLContextlater.