Skip to content

Commit 34effc4

Browse files
committed
Revert "[SPARK-12006][ML][PYTHON] Fix GMM failure if initialModel is not None"
This reverts commit fcd013c. Author: Yin Huai <[email protected]> Closes #10632 from yhuai/pythonStyle. (cherry picked from commit e5cde7a) Signed-off-by: Yin Huai <[email protected]>
1 parent d061b85 commit 34effc4

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

python/pyspark/mllib/clustering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def train(cls, rdd, k, convergenceTol=1e-3, maxIterations=100, seed=None, initia
346346
if initialModel.k != k:
347347
raise Exception("Mismatched cluster count, initialModel.k = %s, however k = %s"
348348
% (initialModel.k, k))
349-
initialModelWeights = list(initialModel.weights)
349+
initialModelWeights = initialModel.weights
350350
initialModelMu = [initialModel.gaussians[i].mu for i in range(initialModel.k)]
351351
initialModelSigma = [initialModel.gaussians[i].sigma for i in range(initialModel.k)]
352352
java_model = callMLlibFunc("trainGaussianMixtureModel", rdd.map(_convert_to_vector),

python/pyspark/mllib/tests.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -474,18 +474,6 @@ def test_gmm_deterministic(self):
474474
for c1, c2 in zip(clusters1.weights, clusters2.weights):
475475
self.assertEqual(round(c1, 7), round(c2, 7))
476476

477-
def test_gmm_with_initial_model(self):
478-
from pyspark.mllib.clustering import GaussianMixture
479-
data = self.sc.parallelize([
480-
(-10, -5), (-9, -4), (10, 5), (9, 4)
481-
])
482-
483-
gmm1 = GaussianMixture.train(data, 2, convergenceTol=0.001,
484-
maxIterations=10, seed=63)
485-
gmm2 = GaussianMixture.train(data, 2, convergenceTol=0.001,
486-
maxIterations=10, seed=63, initialModel=gmm1)
487-
self.assertAlmostEqual((gmm1.weights - gmm2.weights).sum(), 0.0)
488-
489477
def test_classification(self):
490478
from pyspark.mllib.classification import LogisticRegressionWithSGD, SVMWithSGD, NaiveBayes
491479
from pyspark.mllib.tree import DecisionTree, DecisionTreeModel, RandomForest,\

0 commit comments

Comments
 (0)