Highlights
1. K-Mean++. Implement K-Mean++ clustering algorithm in python as follows:
- Read input file ‘as4_1.txt’ given in the Canvas course website. The file is composed of X and Y values in the first and second columns and label in the third column.
- Create myInit() that places the initial k centroids far away from each other in the
4 steps as shown below:
1. Randomly select the first centroid from the data points
2. For each data point compute its distance from the nearest, previously chosen centroid
Use following Euclidean distance function: import numpy as np def euclidean2D(point1, point2):
x1 = point1[0]
x2 = point2[0]
y1 = point1[1]
y2 = point2[1] return np.sqrt((x1 - x2)**2 + (y1 - y2)**2)
3. Select the point having maximum distance from the nearest centroid as the next centroid
4. Repeat steps 2 and 3 until k centroids have been sampled
- Create myAssign() that assigns each example to the nearest centroid
- Create myCentroid() that calculates a new centroid of all points that are assigned to the same centroid.
- Create myUpdateCentroid() that moves the centroids to the center of the examples that were assigned to it
- Create myKmeanPlusPlus() that initially calls myInit(), and then repeats to call myAssign(), myCentroid(), and myUpdateCentroids() until the cluster assignments do not change or a user-defined tolerance or maximum number of iteration is reached. myKmeanPlusPlus() should ask user to receive the following arguments and use the same variable name in the parenthesis:
1. The number of clusters (k)
2. Tolerance (myTol)
3. Maximum number of iterations (myMax) myKmeanPlusPlus()returns a list of new labels.
- Create myPlot() that visualizes plot of clustering result in different colors and markers. You can use any plot method.
This COMP542 - IT Assignment has been solved by our IT experts at My Uni Papers. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
© Copyright 2025 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.