在两个圆圈之间获取一些样本

发布于 2025-01-25 08:26:25 字数 867 浏览 2 评论 0原文

我想在两个圆圈之间获得200个样本,仅限于半径4和9,而在两个圆之间,

我尝试使用sklearn.datasets.make_circles的两个圆圈中的其他200个样本,但我不知道如何完全限制它们之间的这些样本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])

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

被你宠の有点坏 2025-02-01 08:26:26

SET 因子 make_circles的参数与圆的半径比率,并按外圆的半径扩展点。

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])

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])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文