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

    https://github.com/apache/spark/pull/14597#discussion_r78911482
  
    --- Diff: python/pyspark/mllib/feature.py ---
    @@ -271,28 +271,75 @@ def transform(self, vector):
             return JavaVectorTransformer.transform(self, vector)
     
     
    +class ChiSqSelectorType:
    +    """
    +    This class defines the selector types of Chi Square Selector.
    +    """
    +    KBest, Percentile, FPR = range(3)
    +
    +
     class ChiSqSelector(object):
         """
         Creates a ChiSquared feature selector.
     
    -    :param numTopFeatures: number of features that selector will select.
    -
         >>> data = [
         ...     LabeledPoint(0.0, SparseVector(3, {0: 8.0, 1: 7.0})),
         ...     LabeledPoint(1.0, SparseVector(3, {1: 9.0, 2: 6.0})),
         ...     LabeledPoint(1.0, [0.0, 9.0, 8.0]),
         ...     LabeledPoint(2.0, [8.0, 9.0, 5.0])
         ... ]
    -    >>> model = ChiSqSelector(1).fit(sc.parallelize(data))
    +    >>> model = 
ChiSqSelector().setNumTopFeatures(1).fit(sc.parallelize(data))
         >>> model.transform(SparseVector(3, {1: 9.0, 2: 6.0}))
         SparseVector(1, {0: 6.0})
         >>> model.transform(DenseVector([8.0, 9.0, 5.0]))
         DenseVector([5.0])
    +    >>> model = 
ChiSqSelector().setPercentile(0.34).fit(sc.parallelize(data))
    +    >>> model.transform(SparseVector(3, {1: 9.0, 2: 6.0}))
    +    SparseVector(1, {0: 6.0})
    +    >>> model.transform(DenseVector([8.0, 9.0, 5.0]))
    +    DenseVector([5.0])
    +    >>> data = [
    +    ...     LabeledPoint(0.0, SparseVector(4, {0: 8.0, 1: 7.0})),
    +    ...     LabeledPoint(1.0, SparseVector(4, {1: 9.0, 2: 6.0, 3: 4.0})),
    +    ...     LabeledPoint(1.0, [0.0, 9.0, 8.0, 4.0]),
    +    ...     LabeledPoint(2.0, [8.0, 9.0, 5.0, 9.0])
    +    ... ]
    +    >>> model = ChiSqSelector().setAlpha(0.1).fit(sc.parallelize(data))
    +    >>> model.transform(DenseVector([1.0,2.0,3.0,4.0]))
    +    DenseVector([4.0])
     
         .. versionadded:: 1.4.0
         """
    -    def __init__(self, numTopFeatures):
    +    def __init__(self):
    --- End diff --
    
    Hm, does this actually remove the existing constructor or am I missing it? 
it should be possible to use the existing constructor that sets numTopFeatures, 
still.
    
    Also I'm not sure what the relationship between versionadded and `@since` 
is, but seems like you're following the convention here.


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