def kmedoidsWithScores(filenameData, filenameSilhMean, filenameDBS, filenameCHS, kClusters): data = read_sample(str(root) + '\\' + filenameData) #kClusters = canoc(data, kmin, kmax) initial_medoids = randomCenters(len(data), kClusters) kmedoids_instance = kmedoids(data, initial_medoids, metric=metricResearch) kmedoids_instance.process() clusters = kmedoids_instance.get_clusters() predicted = kmedoids_instance.predict(data) silhouetteScore = silhouette(data, clusters).process().get_score() meanSilhouetteScore = np.mean(silhouetteScore) witTXT(meanSilhouetteScore, filenameSilhMean, filepath=root, note='k: ' + str(kClusters)) dbsScore = dbs(data, predicted) witTXT(dbsScore, filenameDBS, filepath=root, note='k: ' + str(kClusters)) chsScore = chs(data, predicted) witTXT(chsScore, filenameCHS, filepath=root, note='k: ' + str(kClusters))
def kmedoidsWithScores(filenameData, filenameSilhMean, nameDBS, nameCHS, kClusters, measure): path = pathlib.Path(str(root) + '\\' + filenameData) if path.is_file(): data = read_sample(path) clusters, predicted = kmedoidsRun(data, kClusters, measure) meanSilhouetteScore = meanSilh(data, clusters) witTXT(meanSilhouetteScore, filenameSilhMean, filepath=root, note=filenameData + " k: " + str(kClusters)) dbsScore = dbs(data, predicted) witTXT(dbsScore, nameDBS, filepath=root, note=filenameData + " k: " + str(kClusters)) chsScore = chs(data, predicted) witTXT(chsScore, nameCHS, filepath=root, note=filenameData + " k: " + str(kClusters))