It seems that I misunderstood the step : Assignment step: Assign each measurement to the cluster with the closest mean value. In case of a tie,assign the measurement to cluster 1 in the assigment. I changed my code now but it does not give me any output right now...
My code:
My code:
import numpy as np import math def clusterAnalysis(reflectance): ref=np.size(reflectance)# all N measurements even=np.any(ref %2==0)# N measurements are even numbers uneven=np.any(ref%2>0)# N measurements are odd number mean1=np.mean(even)#average of even numbers in cluster 2 mean2=np.mean(uneven)# average of odd numbers in cluster 1 sub1=abs(ref-mean1) sub2=abs(ref-mean2) while sub1<=sub2: clusterAssigment="1" else: clusterAssigment="2" return clusterAssigments print(clusterAnalysis(np.array([1.7, 1.6, 1.3, 1.3, 2.8, 1.4, 2.8, 2.6, 1.6, 2.7])))Can anybody help me please? I am struggling very much with this assigment....