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

    https://github.com/apache/spark/pull/8267#discussion_r37555003
  
    --- Diff: python/pyspark/ml/feature.py ---
    @@ -30,7 +30,83 @@
                'NGram', 'Normalizer', 'OneHotEncoder', 'PolynomialExpansion', 
'RegexTokenizer',
                'StandardScaler', 'StandardScalerModel', 'StringIndexer', 
'StringIndexerModel',
                'Tokenizer', 'VectorAssembler', 'VectorIndexer', 'Word2Vec', 
'Word2VecModel',
    -           'PCA', 'PCAModel', 'RFormula', 'RFormulaModel']
    +           'PCA', 'PCAModel', 'RFormula', 'RFormulaModel', 'VectorSlicer']
    +
    +
    +@inherit_doc
    +class VectorSlicer(JavaTransformer, HasInputCol, HasOutputCol):
    +    """
    +    Slice a vector column given indices or names.
    +
    +    >>> from pyspark.mllib.linalg import DenseVector
    +    >>> from pyspark.mllib.linalg import SparseVector
    +    >>> df = sqlContext.createDataFrame([(SparseVector(3, {0: -2.0, 1: 
2.3}),),
    +    ...     (DenseVector([-2.0, 2.3, 0.0]),)], ["userFeatures"])
    +    >>> vectorSlicer = VectorSlicer(indices=[1, 2], 
inputCol="userFeatures", outputCol="features")
    +    >>> vectorSlicer.transform(df).head().features
    +    SparseVector(2, {0: 2.3})
    +    """
    +
    +    # a placeholder to make it appear in the generated doc
    +    indices = Param(Params._dummy(), "indices",
    +                    "An array of indices to select features from a vector 
column." +
    +                    " There can be no overlap with names.")
    +    names = Param(Params._dummy(), "names",
    +                  "An array of feature names to select features from a 
vector column." +
    +                  " There can be no overlap with indices.")
    +
    +    @keyword_only
    +    def __init__(self, indices=[], names=[], inputCol=None, 
outputCol=None):
    --- End diff --
    
    Do not use `[]` or `{}` as the default value in Python API, because they 
are mutable and shared among instances. Please use `None` instead. Again, we 
should move Python API to a separate PR.


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