Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/8102#discussion_r37350798
--- Diff: python/pyspark/ml/feature.py ---
@@ -950,6 +950,92 @@ class VectorIndexerModel(JavaModel):
@inherit_doc
+class VectorSlicer(JavaTransformer, HasInputCol, HasOutputCol):
+ """
+ .. note:: Experimental
+
+ This class takes a feature vector and outputs a new feature vector
with a subarray
+ of the original features.
+
+ The subset of features can be specified with either indices
(`setIndices()`)
+ or names (`setNames()`). At least one feature must be selected.
Duplicate features
+ are not allowed, so there can be no overlap between selected indices
and names.
+
+ The output vector will order features with the selected indices first
(in the order given),
+ followed by the selected names (in the order given).
+
+ >>> from pyspark.mllib.linalg import Vectors
+ >>> df = sqlContext.createDataFrame([
+ ... (Vectors.dense([-2.0, 2.3, 0.0, 0.0, 1.0]),),
+ ... (Vectors.dense([0.0, 0.0, 0.0, 0.0, 0.0]),),
+ ... (Vectors.dense([0.6, -1.1, -3.0, 4.5, 3.3]),)], ["features"])
+ >>> vs = VectorSlicer(inputCol="features", outputCol="expected",
indices=[1, 4])
--- End diff --
Rename "expected" to "sliced" since this is an example
---
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]