y = random.randint(int(-radii[index][1]) \ ,int(radii[index][1])) if (x**2 + y**2)**0.5 >= radii[index][0] and\ (x**2 + y**2)**0.5 <= radii[index][1]: instanceCount += 1 features.append([x,y]) labels.append(label) #Silhouette score score = sklearn.metrics.silhouette_score(features, labels) #Beta Values betaV = beta(features,labels) #Plotting for i in range(len(features)): if labels[i] == 0: plt.plot(features[i][0],features[i][1],'bo') else: plt.plot(features[i][0],features[i][1],'ro') #Saving name = str(datasetNumber) plt.savefig('plots/' + name + '.png') plt.clf() file = open('datasets/'+ name + '.txt','w')
home = os.getcwd() datasetFolder = os.path.join(home, "datasets") betaFile = open("betaValues2.txt", "w") for i in range(600): print(i) fileName = os.path.join(datasetFolder, str(i) + ".txt") file = open(fileName, 'r') X = [] y = [] classDistribution = [0, 0] for i in file: i = i.strip("\n") i = i.split(",") temp = [] for j in range(len(i)): if j == 2: y.append(int(i[j])) classDistribution[int(i[j])] += 1 else: temp.append(int(i[j])) X.append(temp) file.close() betaValue = beta(X, y, classDistribution) for i in betaValue: betaFile.write(str(i) + ",") betaFile.write("\n") betaFile.close()