Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/8485#discussion_r38116030
--- Diff: python/pyspark/ml/feature.py ---
@@ -167,6 +167,65 @@ def getSplits(self):
@inherit_doc
+class DCT(JavaTransformer, HasInputCol, HasOutputCol):
+ """
+ A feature transformer that takes the 1D discrete cosine transform of a
real vector. No zero
+ padding is performed on the input vector.
+ It returns a real vector of the same length representing the DCT. The
return vector is scaled
+ such that the transform matrix is unitary (aka scaled DCT-II).
+
+ More information on
`https://en.wikipedia.org/wiki/Discrete_cosine_transform#DCT-II Wikipedia`.
+
+ >>> from pyspark.mllib.linalg import Vectors
+ >>> df = sqlContext.createDataFrame([(Vectors.dense([5.0, 8.0,
6.0]),)], ["vec"])
+ >>> dct = DCT(inverse=False, inputCol="vec", outputCol="resultVec")
+ >>> dct.transform(df).head().resultVec
+ DenseVector([10.969..., -0.707..., -2.041...])
+ >>> dct.setInverse(True).transform(df).head().resultVec
--- End diff --
I would transform `resultVec` back to `origVec` to show that this is the
inverse.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]