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

    https://github.com/apache/spark/pull/6087#discussion_r30195888
  
    --- Diff: python/pyspark/mllib/clustering.py ---
    @@ -166,12 +166,39 @@ class GaussianMixtureModel(object):
         True
         >>> labels[3]==labels[4]
         True
    +    >>> clusterdata_3 = sc.parallelize([[-5.1971], [-2.5359], [-3.8220],
    +    ...                                 [-5.2211], [-5.0602],  [4.7118],
    +    ...                                 [6.8989], [3.4592],  [4.6322],
    +    ...                                 [5.7048],  [4.6567], [5.5026],
    +    ...                                 [4.5605],  [5.2043],  [6.2734]])
    +    >>> im = GaussianMixtureModel([0.5, 0.5],
    +    ...      [MultivariateGaussian(Vectors.dense([-1.0]), DenseMatrix(1, 
1, [1.0])),
    +    ...      MultivariateGaussian(Vectors.dense([1.0]), DenseMatrix(1, 1, 
[1.0]))])
    +    >>> model = GaussianMixture.train(clusterdata_3, 2, initialModel=im)
    +    >>> model.weights
    +    DenseVector([0.3333..., 0.6667...])
    +    >>> model.gaussians[0].mu
    +    DenseVector([-4.3673...])
    +    >>> model.gaussians[0].sigma.toArray()
    +    array([[ 1.1098...]])
         """
     
         def __init__(self, weights, gaussians):
    -        self.weights = weights
    -        self.gaussians = gaussians
    -        self.k = len(self.weights)
    +        self._weights = weights
    +        self._gaussians = gaussians
    +        self._k = len(self._weights)
    +
    +    @property
    +    def weights(self):
    --- End diff --
    
    Thanks for adding these!  Can you also please add doc (copied from the 
Scala doc)?
    Relatedly, I noticed that the Scala doc for GaussianMixtureModel's weights, 
gaussians params are messed up (still using weight, mu, sigma).  Would you mind 
correcting that in this PR?  Thanks!


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to