import numpy as np
import pandas as pd
import math
import matplotlib.pyplot as plt
num_data = 1000
center = np.array([5.0,5.0])
radiu_inner = 2
radiu_outer = 4
num_inner = num_data //4
num_outer = num_data - num_inner
data = []
theta = 0.0
for i in range(num_inner):
pho = (theta % 360) * math.pi / 180
tmp = np.zeros(2,dtype=float)
tmp[0] = radiu_inner * math.cos(pho) + np.random.rand(1) + center[0]
tmp[1] = radiu_inner * math.sin(pho) + np.random.rand(1) + center[1]
data.append(tmp)
theta += 3
for j in range(num_outer):
pho = (theta % 360) * math.pi / 180
tmp = np.zeros(2,dtype=float)
tmp[0] = radiu_outer * math.cos(pho) + np.random.rand(1) + center[0]
tmp[1] = radiu_outer * math.sin(pho) + np.random.rand(1) + center[1]
data.append(tmp)
theta += 2
label = np.zeros(num_data)
for i in range(num_inner,num_data):
label[i] = 1
data = np.array(data)
print(data.shape)
print(label.shape)
label = np.vstack(label)
X = np.hstack((data,label))
# X = np.concatenate((data,label.T),axis=0)
print(X.shape)
plt.scatter(X[:,0],X[:,1],c=X[:,2])
plt.show()
X = pd.DataFrame(X)
X.to_csv(r'E:\dataset\clusterData\two_circles.csv',header=None,index=None)