You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Sajjad Bey (JIRA)" <ji...@apache.org> on 2016/04/23 00:02:12 UTC

[jira] [Commented] (SPARK-11057) SQL: corr and cov for many columns

    [ https://issues.apache.org/jira/browse/SPARK-11057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15254778#comment-15254778 ] 

Sajjad Bey commented on SPARK-11057:
------------------------------------

I have been trying to use correlation on a matrix with many columns. @NarineK menthioned R like correlation. I wish we had something like what [pandas](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.corr.html) offers. It handles missing data automatically. Take a look [here](http://stackoverflow.com/questions/31619578/numpy-corrcoef-compute-correlation-matrix-while-ignoring-missing-data). Even the [corr()](http://spark.apache.org/docs/latest/api/python/pyspark.mllib.html#pyspark.mllib.stat.Statistics) function from MLlib can not handle missing data. These features are really missing from SparkSQL:

- Apply correlation on all columns and return a matrix

- Handle missing data automatically like how [pandas ](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.corr.html)does

> SQL: corr and cov for many columns
> ----------------------------------
>
>                 Key: SPARK-11057
>                 URL: https://issues.apache.org/jira/browse/SPARK-11057
>             Project: Spark
>          Issue Type: New Feature
>          Components: SQL
>            Reporter: Narine Kokhlikyan
>
> Hi there,
> As we know R has the option to calculate the correlation and covariance for all columns of a dataframe or between columns of two dataframes.
> If we look at apache math package we can see that, they have that too. 
> http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/stat/correlation/PearsonsCorrelation.html#computeCorrelationMatrix%28org.apache.commons.math3.linear.RealMatrix%29
> In case we have as input only one DataFrame:
> ------------------------------------------------------
> for correlation:
> cor[i,j] = cor[j,i]
> and for the main diagonal we can have 1s.
> ---------------------
> for covariance: 
> cov[i,j] = cov[j,i]
> and for main diagonal: we can compute the variance for that specific column:
> See:
> http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/stat/correlation/Covariance.html#computeCovarianceMatrix%28org.apache.commons.math3.linear.RealMatrix%29
> Let me know what do you think.
> I'm working on this and will make a pull request soon.
> Thanks,
> Narine



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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