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

    https://github.com/apache/spark/pull/16715#discussion_r100427633
  
    --- Diff: python/pyspark/ml/feature.py ---
    @@ -755,6 +947,101 @@ def maxAbs(self):
     
     
     @inherit_doc
    +class MinHashLSH(JavaEstimator, LSHParams, HasInputCol, HasOutputCol, 
HasSeed,
    +                 JavaMLReadable, JavaMLWritable):
    +
    +    """
    +    .. note:: Experimental
    +
    +    LSH class for Jaccard distance.
    +    The input can be dense or sparse vectors, but it is more efficient if 
it is sparse.
    +    For example, `Vectors.sparse(10, [(2, 1.0), (3, 1.0), (5, 1.0)])` 
means there are 10 elements
    +    in the space. This set contains elements 2, 3, and 5. Also, any input 
vector must have at
    +    least 1 non-zero index, and all non-zero values are treated as binary 
"1" values.
    +
    +    .. seealso:: `Wikipedia on MinHash 
<https://en.wikipedia.org/wiki/MinHash>`_
    +
    +    >>> from pyspark.ml.linalg import Vectors
    +    >>> data = [(0, Vectors.sparse(6, [0, 1, 2], [1.0, 1.0, 1.0]),),
    +    ...         (1, Vectors.sparse(6, [2, 3, 4], [1.0, 1.0, 1.0]),),
    +    ...         (2, Vectors.sparse(6, [0, 2, 4], [1.0, 1.0, 1.0]),)]
    +    >>> df = spark.createDataFrame(data, ["id", "features"])
    +    >>> mh = MinHashLSH(inputCol="features", outputCol="hashes", 
seed=12345)
    +    >>> model = mh.fit(df)
    +    >>> model.transform(df).head()
    +    Row(id=0, features=SparseVector(6, {0: 1.0, 1: 1.0, 2: 1.0}), 
hashes=[DenseVector([-1638925...
    +    >>> data2 = [(3, Vectors.sparse(6, [1, 3, 5], [1.0, 1.0, 1.0]),),
    +    ...          (4, Vectors.sparse(6, [2, 3, 5], [1.0, 1.0, 1.0]),),
    +    ...          (5, Vectors.sparse(6, [1, 2, 4], [1.0, 1.0, 1.0]),)]
    +    >>> df2 = spark.createDataFrame(data2, ["id", "features"])
    +    >>> key = Vectors.sparse(6, [1, 2], [1.0, 1.0])
    +    >>> model.approxNearestNeighbors(df2, key, 1).collect()
    +    [Row(id=5, features=SparseVector(6, {1: 1.0, 2: 1.0, 4: 1.0}), 
hashes=[DenseVector([-163892...
    +    >>> model.approxSimilarityJoin(df, df2, 0.6).select("datasetA.id",
    --- End diff --
    
    same as above, except distcol could be "jaccardSimilarity" or something.


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