You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by lins05 <gi...@git.apache.org> on 2016/07/10 14:43:32 UTC

[GitHub] spark pull request #13248: [SPARK-15194] [ML] Add Python ML API for Multivar...

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

    https://github.com/apache/spark/pull/13248#discussion_r70182969
  
    --- Diff: python/pyspark/ml/stat/distribution.py ---
    @@ -0,0 +1,267 @@
    +#
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#    http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +
    +from pyspark.ml.linalg import DenseVector, DenseMatrix, Vector
    +import numpy as np
    +
    +__all__ = ['MultivariateGaussian']
    +
    +
    +
    +class MultivariateGaussian():
    +    """
    +    This class provides basic functionality for a Multivariate Gaussian (Normal) Distribution. In
    +     the event that the covariance matrix is singular, the density will be computed in a
    +    reduced dimensional subspace under which the distribution is supported.
    +    (see [[http://en.wikipedia.org/wiki/Multivariate_normal_distribution#Degenerate_case]])
    +
    +    mu The mean vector of the distribution
    +    sigma The covariance matrix of the distribution
    +
    +
    +    >>> mu = Vectors.dense([0.0, 0.0])
    +    >>> sigma= DenseMatrix(2, 2, [1.0, 1.0, 1.0, 1.0])
    +    >>> x = Vectors.dense([1.0, 1.0])
    +    >>> m = MultivariateGaussian(mu, sigma)
    +    >>> m.pdf(x)
    +    0.0682586811486
    --- End diff --
    
    To run the doctest, I think we need to call the `doctest.testmod()` explicitly like other modules do. Check [mllib/util.py](https://github.com/apache/spark/blob/v2.0.0-rc2/python/pyspark/mllib/util.py#L509-L528).
    
    Also need to add this module to the `python_test_goals` to pyspark_ml module object of [dev/sparktestsupport/modules.py](https://github.com/apache/spark/blob/v2.0.0-rc2/dev/sparktestsupport/modules.py#L401-L411)


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