This is a review of K-Means Clustering. It aims to refresh your memory of what you have learned in class.
Please download the review notebook by right-clicking the link. Then, select "Save link as..." to save the file to your local disk. Next, upload it to your Google Drive and open it using Google Colab.
A number of lab tasks are given to you to familiarize yourself with the K-Mean algorithm (and practice your NumPy programming skills). Please download the lab tasks notebook by right-clicking the link. Then, select "Save link as..." to save the file to your local disk. Next, upload it to your Google Drive and open it using Google Colab.
lab4_tasks.py
(the name should be the same, including its case), and submit the zip file to ZINCThis list is incomplete; you can help by expanding it
This sections shows the modification that was made to the corresponding files. Therefore, you can either choose to update the file yourself or download the file and move your code.
lab4_tasks.ipynb
def isNotebook():
, an extra condition shell == 'Shell'
is added for the code to work in GoogleColab.
if isNotebook:
is changed to if isNotebook():
.
print('SSE: ', sse := SSE(X, output, 3, kmean.centroid))
is replaced with
sse = SSE(X, output, 3, kmean.centroid)
print('SSE: ', sse)
import matplotlib.pyplot as plt
on the second line is removed.
sse
is changed to round(sse, 5)
to avoid the rounding error of floating points numbers.