Skip to main content

Posts

Showing posts from September, 2020

Python K Medoids

def kmedoids(X, k,            starting_medoids=None,            max_steps=50):     if starting_medoids is None:         medoids = init_medoids(X, k)         print(medoids)     else:         medoids = starting_medoids             converged = False     labels = np.zeros(len(X))     i = 1         # Delete a file if it exists     if os.path.exists("KMedoids_Results.txt"):         os.remove("KMedoids_Results.txt")            f = open("KMedoids_Results.txt", "a")     start_time = time.time()     f.write('The program starting time '...