Example #1
0
def part1_q2(dataset, show_graph=False):
    print(">>> PART 1: QUESTION 2")
    clustering = kmeans(dataset, 2, initCentroids=[('i1', 4, 6), ('i2', 5, 4)], distance_type='Euclidean')
    printTable(clustering["centroids"])
    if show_graph:
        showClusters2D(clustering)
    print('')
Example #2
0
def part1_q4(dataset, show_graph=False):
    print(">>> PART 1: QUESTION 4")
    clustering = kmeans(dataset, 2, initCentroids=[('i1', 3, 2), ('i2', 4, 8)], distance_type='Manhattan')
    printTable(clustering["centroids"])
    if show_graph:
        showClusters2D(clustering)
    print('')
Example #3
0
# hw_6.py

from kmeans import loadCSV
from kmeans import kmeans
from kmeans import printTable

dataset = loadCSV('iris.data')
clustering = kmeans(dataset, 3, False)
printTable(clustering["centroids"])
print(clustering["withinss"])