コード例 #1
0
    def test_kmeans_k2(self):
        """ Test k=2 also with more points"""

        data, centerstrue = DataSets.make(self.sc, "kmeans",
                                          k=2, nrecords=50, npartitions=5, seed=42, returnparams=True)
        centerstrue = KMeansModel(centerstrue)

        model = KMeans(k=2, maxIterations=20).fit(data)

        labels = array(model.predict(data).values().collect())
        labelstrue = array(centerstrue.predict(data).values().collect())

        assert(array_equal(labels, labelstrue) or array_equal(labels, 1 - labelstrue))
コード例 #2
0
ファイル: test_clustering.py プロジェクト: vpomponiu/thunder
    def test_kmeans_k2(self):
        """ Test k=2 also with more points"""

        data, centerstrue = DataSets.make(self.sc, "kmeans",
                                          k=2, nrecords=50, npartitions=5, seed=42, returnparams=True)
        centerstrue = KMeansModel(centerstrue)

        model = KMeans(k=2, maxiter=20, tol=0.001, init="sample").train(data)

        labels = array(model.predict(data).values().collect())
        labelstrue = array(centerstrue.predict(data).values().collect())
        print(labels)
        print(labelstrue)

        assert(array_equal(labels, labelstrue) or array_equal(labels, 1 - labelstrue))
コード例 #3
0
ファイル: test_clustering.py プロジェクト: rheiland/thunder
    def test_kmeans_k2(self):
        """ Test k=2 also with more points"""

        data, centerstrue = DataSets.make(
            self.sc, "kmeans", k=2, nrecords=50, npartitions=5, seed=42, returnparams=True
        )
        centerstrue = KMeansModel(centerstrue)

        model = KMeans(k=2, maxiter=20, tol=0.001, init="sample").train(data)

        labels = array(model.predict(data).values().collect())
        labelstrue = array(centerstrue.predict(data).values().collect())
        print(labels)
        print(labelstrue)

        assert array_equal(labels, labelstrue) or array_equal(labels, 1 - labelstrue)
コード例 #4
0
    def test_KMeans_k2(self):
        """ Test k=2 also with more points"""

        data, centersTrue = DataSets.make(self.sc,
                                          "kmeans",
                                          k=2,
                                          nrecords=50,
                                          npartitions=5,
                                          seed=42,
                                          returnParams=True)
        centersTrue = KMeansModel(centersTrue)

        model = KMeans(k=2, maxIterations=20).fit(data)

        labels = array(model.predict(data).values().collect())
        labelsTrue = array(centersTrue.predict(data).values().collect())

        assert (array_equal(labels, labelsTrue)
                or array_equal(labels, 1 - labelsTrue))