vendredi 8 février 2019

What is the best way to test performance of different functions in my algorithm implemented in Python?

I have tried to search the site but I have not been able to find the answer that I'm looking for, I would like for someone to point me in the right direction.

I have been developing a deterministic k-means algorithm and I'm trying to test it's performance using different initialization functions, and I was wondering what is the best way to do this. Currently this is what I'm doing:

# . . .
if(init == RANDOM):
    c_means = (unique_datap[np.random.choice(unique_datap.shape[0], k, replace = False)]).astype(np.float32)
elif(init == FFT):
    c_means = deterministic_fft(unique_datap, el_count, k, rgb_distance).astype(np.float32)
elif(init == UMDI):
    c_means = uniform_mode_dist_init(unique_datap, el_count, k, rgb_distance).astype(np.float32)
else:
    raise ValueError('Unknown initialization')
# . . .

Obviously this is not very practical nor elegant, what could be a better way to do this. I'm interested in saving the outputs of the algorithm as well as measuring it's execution time and maybe the amount of memory it used. Any help or direction would be appreciated, I'm not really looking for a quick answer (although it would be still greatly appreciated), I can take all the time I want to read whatever source you can point me to.

Aucun commentaire:

Enregistrer un commentaire