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

    https://github.com/apache/spark/pull/8267#discussion_r37346559
  
    --- Diff: docs/ml-features.md ---
    @@ -1389,3 +1389,145 @@ print(output.select("features", "clicked").first())
     
     # Feature Selectors
     
    +## VectorSlicer
    +
    +`VectorSlicer` is a transformer that takes a feature vector and outputs a 
new feature vector with a sub-array of the original features. It is useful for 
extracting features from a vector column.
    +
    +`VectorSlicer` accepts a vector column with a specified indices, then 
outputs a new vector column whose values are selected via those indices. There 
are two types of indices, 
    +
    + 1. Integer indices that represents the real indices in the vector, 
`setIndices()`;
    +
    + 2. String indices that represents the names of features in the vector, 
`setNames()`.
    +
    +Specify by integer and string are both acceptable, moreover, you can use 
integer index and string name simultaneously. At least one feature must be 
selected. Duplicate features are not allowed, so there can be no overlap 
between selected indices and names. Note that if names of features are 
selected, an exception will be threw out when encountering with empty input 
attributes.
    +
    +The output vector will order features with the selected indices first (in 
the order given), followed by the selected names (in the order given).
    +
    +**Examples**
    +
    +Suppose that we have a DataFrame with the column `userFeatures`:
    +
    +~~~
    + userFeatures     
    +------------------
    + [0.0, 10.0, 0.5] 
    +~~~
    +
    +`userFeatures` is a vector column that contains three user features. 
Assuming that the first column of `userFeatures` are all zeros, so we want to 
remove it and only the last two columns are selected. The `VectorSlicer` 
selects the last two elements with `setIndices(1, 2)` then produces a new 
vector column named `features`:
    +
    +~~~
    + userFeatures     | features
    +------------------|-----------------------------
    + [0.0, 10.0, 0.5] | [10.0, 0.5]
    +~~~
    +
    +Suppose also that we have a potential input attributes for the 
`userFeatures`, i.e. `["f1", "f2", "f3"]`, then we can use `setNames("f2", 
"f3")` to select them.
    +
    +~~~
    + userFeatures     | features
    +------------------|-----------------------------
    + [0.0, 10.0, 0.5] | [10.0, 0.5]
    + ["f1", "f2", "f3"] | ["f2", "f3"]
    +~~~
    +
    +**NOTE**
    +
    +`VectorSlicer` of Python version does not supprt selecting by names 
currently.
    --- End diff --
    
    nit: "The Python version of `VectorSlicer`..."
    supprt -> support


---
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