IbraDje / PFCM

Possiblistic Fuzzy C-Means Algorithm in Python
Other
13 stars 2 forks source link

Add epsilon to avoid divide by 0 #4

Closed kroegern1 closed 2 years ago

kroegern1 commented 3 years ago

It would be good to add a small number like epsilon = 0.000000001 or something to the pdistfcm function and whenever you have a denominator that could be 0.

def pdistfcm(cntr, data):
    out = np.zeros(shape=(cntr.shape[0], data.shape[0]))
    for k in range(cntr.shape[0]):
        out[k] = np.sqrt(np.sum((np.power(data-cntr[k], 2)).T, axis=0)) + 0.000000000001 #add eps to avoid divide by 0
    return out
IbraDje commented 2 years ago

I've added a small constant ! Thanks for pointing out the issues !