Skip to content

Commit e5cde7a

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.
1 parent b673852 commit e5cde7a

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
@@ -475,18 +475,6 @@ def test_gmm_deterministic(self):
475475
for c1, c2 in zip(clusters1.weights, clusters2.weights):
476476
self.assertEqual(round(c1, 7), round(c2, 7))
477477

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

0 commit comments

Comments
 (0)