Principal Component Analysis

# Principal Component Analysis

Computes the top k principal component coefficients for the m-by-n data matrix X. Rows of X correspond to observations and columns correspond to variables. The coefficient matrix is n-by-k. Each column of coeff contains coefficients for one principal component, and the columns are in descending
order of component variance. This function centers the data and uses the singular value decomposition (SVD) algorithm.

# Testing
Tests included:
 * All principal components
 * Only top k principal components

# Documentation

# Example Usage 
import org.apache.spark.SparkContext
import org.apache.spark.mllib.linalg.PCA
import org.apache.spark.mllib.linalg.SparseMatrix
import org.apache.spark.mllib.linalg.MatrixEntry

// Load and parse the data file
val data = sc.textFile("mllib/data/als/test.data").map { line =>
  val parts = line.split(',')
  MatrixEntry(parts(0).toInt, parts(1).toInt, parts(2).toDouble)
}
val m = 4
val n = 4
val k = 1

// recover top principal component
val coeffs = PCA.computePCA(SparseMatrix(data, m, n), k)

{% endhighlight %}