PySpark and PCA: How can I extract the eigenvectors of this PCA? How can I calculate how much variance they are explaining?
I am reducing the dimensionality of a Spark DataFrame with the PCA model with PySpark (using the spark ml library) as follows: pca = PCA(k=3, inputCol="features", outputCol="pca_features") model = pca.fit(data) where data is a Spark DataFrame with one column labeled features which is a DenseVector of three dimensions: data.take(1) Row(features=DenseVector([0.4536,-0.43218, 0.9876]), label=u'class1') After fitting, I transform the data: transformed = model.transform(data) transformed.first() Row(features=DenseVector([0.4536,-0.43218, 0.9876]), label=u'class1', pca_features=DenseVector([-0.33256
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.