'Getting some sample between two circles

I want to get 200 samples between two circles limited to radii 4 and 9, and another 200 samples between two circles limited to radii 0 and 6

I tried with sklearn.datasets.make_circles but I do'nt know how to exactly limited them between those radii

from sklearn.datasets import make_circles

n_samples = (200,200)
noise = (0.2,0.2)
features, labels = make_circles(n_samples=n_samples, noise=noise, factor = 0.000001)

#center of circles = (1.5,0)
for i in range(len(features)):
    features[i][0]+= 1.5
    
df = pd.DataFrame(dict(x=features[:,0], y=features[:,1], label=labels))
grouped = df.groupby('label')
colors = {0:'red', 1:'blue'}

fig, ax = plt.subplots(figsize=(5, 5))

for key, group in grouped:
    group.plot(ax=ax, kind='scatter', x='x', y='y', marker='.', label=key, color=colors[key])

enter image description here



Solution 1:[1]

Set factor parameter of make_circles to the ratio of radii of the circles and scale the points by the radii of the outer circle.

from sklearn.datasets import make_circles

n_samples = (200,200)
noise = (0.2,0.2)
factor = 4/9
features, labels = make_circles(n_samples=n_samples, noise=noise, factor=factor)

#center of circles = (1.5,0)
for i in range(len(features)):
    features[i][0] += 1.5 + 8*features[i][0]
    features[i][1] += 8*features[i][1]
    
df = pd.DataFrame(dict(x=features[:,0], y=features[:,1], label=labels))
grouped = df.groupby('label')
colors = {0:'red', 1:'blue'}

fig, ax = plt.subplots(figsize=(5, 5))

for key, group in grouped:
    group.plot(ax=ax, kind='scatter', x='x', y='y', marker='.', label=key, color=colors[key])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shuhana Azmin