Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7190#discussion_r34743436
  
    --- Diff: python/pyspark/ml/feature.py ---
    @@ -1030,6 +1030,67 @@ class Word2VecModel(JavaModel):
         """
     
     
    +@inherit_doc
    +class PCA(JavaEstimator, HasInputCol, HasOutputCol):
    +    """
    +    PCA trains a model to project vectors to a low-dimensional space using 
PCA.
    +
    +    >>> from pyspark.mllib.linalg import Vectors
    +    >>> data = [(Vectors.sparse(5, [(1, 1.0), (3, 7.0)]),),
    +    ...     (Vectors.dense([2.0, 0.0, 3.0, 4.0, 5.0]),),
    +    ...     (Vectors.dense([4.0, 0.0, 0.0, 6.0, 7.0]),)]
    +    >>> df = sqlContext.createDataFrame(data,["features"])
    +    >>> pca = PCA(k=2, inputCol="features", outputCol="pca_features")
    +    >>> model = pca.fit(df)
    +    >>> model.transform(df).collect()[0].pca_features
    +    DenseVector([1.648..., -4.013...])
    +    """
    +
    +    # a placeholder to make it appear in the generated doc
    +    k = Param(Params._dummy(), "k", "the number of principal components")
    +
    +    @keyword_only
    +    def __init__(self, k=None, inputCol=None, outputCol=None):
    +        """
    +        __init__(self, k=None, inputCol=None, outputCol=None)
    +        """
    +        super(PCA, self).__init__()
    +        self._java_obj = 
self._new_java_obj("org.apache.spark.ml.feature.PCA", self.uid)
    +        self.k = Param(self, "k", "the number of principal components")
    +        kwargs = self.__init__._input_kwargs
    +        self.setParams(**kwargs)
    +
    +    @keyword_only
    +    def setParams(self, k=None, inputCol=None, outputCol=None):
    +        """
    +        setParams(self, k=None, inputCol=None, outputCol=None)
    +        Set params for this PCA.
    +        """
    +        kwargs = self.setParams._input_kwargs
    +        return self._set(**kwargs)
    +
    +    def setK(self, value):
    +        """
    +        Sets the value of :py:attr:`k`.
    +        """
    +        self._paramMap[self.k] = value
    --- End diff --
    
    return self


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to