def test_with_hartigan(self):
        """A tiny dataset which can't possibly work here"""

        dataset = testloader.load_hartigan()

        with self.assertRaises(ValueError):
            bfinit.generate(dataset.data, 3)
Exemplo n.º 2
0
def run_clustering(algorithm):
    """Run all datasets"""

    _run_dataset('HART', testloader.load_hartigan(), 3, algorithm)
    _run_dataset('IRIS', testloader.load_iris(), 3, algorithm)
    _run_dataset('SOYS', testloader.load_soy_small(), 4, algorithm)
    _run_dataset('WINE', testloader.load_wine(), 3, algorithm)
    _run_dataset('WBCO', testloader.load_wbco(), 2, algorithm)
Exemplo n.º 3
0
    def _test_with_hartigan(self):
        """This is left as TODO as it exposes the fact that the algorithm is
        highly sensitive to the values of R and C being specified for each
        dataset. This seems potentially problematic"""

        dataset = testloader.load_hartigan()
        centroids = macqueen.generate(dataset.data, 3)
        self.assertEqual((3, 3), centroids.shape)
Exemplo n.º 4
0
import sys

from sklearn.cluster import KMeans

from datasets import testloader
from initialisations import spss2010 as alg

dsname = ''
if len(sys.argv) > 1:
    dsname = sys.argv[1]

if dsname == 'iris':
    dataset = testloader.load_iris()
    num_clusters = 3
else:
    dataset = testloader.load_hartigan()
    num_clusters = 3

# dataset = testloader.load_soy_small()
# num_clusters = 4

data = dataset.data
centroids = alg.generate(data, num_clusters)

print(centroids)

est = KMeans(n_clusters=num_clusters, init=centroids, n_init=1)
est.fit(dataset.data)

print("Final centres:\n", est.cluster_centers_)
Exemplo n.º 5
0
    def test_with_hartigan(self):
        """A tiny dataset which can't possibly work here"""  # why not, Simon?

        dataset = testloader.load_hartigan()
        centroids = ikminit_c.generate(dataset.data, 3)
        self.assertEqual((3, 3), centroids.shape)
Exemplo n.º 6
0
    def test_with_hartigan(self):
        """A tiny dataset which led to problems with empty clusters"""

        dataset = testloader.load_hartigan()
        centroids = hand.generate(dataset.data, 3)
        self.assertEqual((3, 3), centroids.shape)