spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sethah <...@git.apache.org>
Subject [GitHub] spark pull request #16715: [Spark-18080][ML][PYTHON] Python API & Examples f...
Date Mon, 13 Feb 2017 19:45:28 GMT
Github user sethah commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16715#discussion_r100869085
  
    --- Diff: python/pyspark/ml/feature.py ---
    @@ -120,6 +122,198 @@ def getThreshold(self):
             return self.getOrDefault(self.threshold)
     
     
    +class LSHParams(Params):
    +    """
    +    Mixin for Locality Sensitive Hashing (LSH) algorithm parameters.
    +    """
    +
    +    numHashTables = Param(Params._dummy(), "numHashTables", "number of hash tables, where
" +
    +                          "increasing number of hash tables lowers the false negative
rate, " +
    +                          "and decreasing it improves the running performance.",
    +                          typeConverter=TypeConverters.toInt)
    +
    +    def __init__(self):
    +        super(LSHParams, self).__init__()
    +
    +    @since("2.2.0")
    +    def setNumHashTables(self, value):
    +        """
    +        Sets the value of :py:attr:`numHashTables`.
    +        """
    +        return self._set(numHashTables=value)
    +
    +    @since("2.2.0")
    +    def getNumHashTables(self):
    +        """
    +        Gets the value of numHashTables or its default value.
    +        """
    +        return self.getOrDefault(self.numHashTables)
    +
    +
    +class LSHModel(JavaModel):
    +    """
    +    Mixin for Locality Sensitive Hashing (LSH) models.
    +    """
    +
    +    @since("2.2.0")
    +    def approxNearestNeighbors(self, dataset, key, numNearestNeighbors, distCol="distCol"):
    +        """
    +        Given a large dataset and an item, approximately find at most k items which have
the
    +        closest distance to the item. If the :py:attr:`outputCol` is missing, the method
will
    +        transform the data; if the :py:attr:`outputCol` exists, it will use that. This
allows
    +        caching of the transformed data when necessary.
    +
    +        .. note:: This method is experimental and will likely change behavior in the
next release.
    +
    +        :param dataset: The dataset to search for nearest neighbors of the key.
    +        :param key: Feature vector representing the item to search for.
    +        :param numNearestNeighbors: The maximum number of nearest neighbors.
    +        :param distCol: Output column for storing the distance between each result row
and the key.
    +                        Use "distCol" as default value if it's not specified.
    +        :return: A dataset containing at most k items closest to the key. A distCol is
added
    +                 to show the distance between each row and the key.
    +        """
    +        return self._call_java("approxNearestNeighbors", dataset, key, numNearestNeighbors,
    +                               distCol)
    +
    +    @since("2.2.0")
    --- End diff --
    
    I think we've decided not to put since tags in parent classes, since they'll be wrong
for future derived classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message