Skip to content

[FIX] #1 Updated content in README.md and comments in test.py #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# KMeansalgorithm
The KMeanss Algorithm is one of the most basic algorithms in unsupervised learninng and is used for classification.Here is a basic implementation of the kmeans algorithm which is used to classify a cluster of data into two groups
# K-Means Algorithm
The K-Means Algorithm is one of the most basic algorithms in unsupervised learning and is used for classification. Here is a basic implementation of the K-Means Algorithm which is used to classify a cluster of data into two groups.
10 changes: 5 additions & 5 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
cluster_2=list()#First cluster

def E_distance(a,b):
return math.pow(math.pow(a[1]-b[1],2)+math.pow(a[0]-b[0],2),0.5) #computing the euclidean Distance between two points
return math.pow(math.pow(a[1]-b[1],2)+math.pow(a[0]-b[0],2),0.5) #Computing the Euclidean Distance between two points
for i in dataset:
if E_distance(i,mean1)<E_distance(i,mean2):
cluster_1.append(i)#Clustering the elements
Expand All @@ -19,15 +19,15 @@ def average(a): #Used for finding the centroid of all the points belonging to
centroid[0]=sum(a[i][0] for i in range(len(a)))/len(a)
centroid[1]=sum(a[i][1] for i in range(len(a)))/len(a)
return centroid
while average(cluster_1)!=mean1 and average(cluster_2)!=mean2:#Conition for stopping the KMeans Algorithms
while average(cluster_1)!=mean1 and average(cluster_2)!=mean2:#Condition for stopping the K-Means Algorithms

mean1=average(cluster_1)#the first new mean/centroid
mean2=average(cluster_2)#the second new mean/centroid
mean1=average(cluster_1)#The first new mean/centroid
mean2=average(cluster_2)#The second new mean/centroid
cluster_1=list()
cluster_2=list()
for i in dataset:
if E_distance(i,mean1)<E_distance(i,mean2):
cluster_1.append(i)#Forming the new cLuster
cluster_1.append(i)#Forming the new cluster
else:
cluster_2.append(i)#Forming the new cluster
print(mean1)
Expand Down