sklearn --make_moons

*#1. 参数

A simple toy dataset to visualize clustering and classification algorithms. Read more in the User Guide.

Parameters
n_samples:  int or two-element tuple, optional (default=100)
If int, the total number of points generated. If two-element tuple, number of points in each of two moons.

shuffle: bool, optional (default=True)
Whether to shuffle the samples.

noise: double or None (default=None)
Standard deviation of Gaussian noise added to the data.

random_state:  int, RandomState instance, default=None
Determines random number generation for dataset shuffling and noise. Pass an int for reproducible output across multiple function calls. See Glossary.

Returns
Xarray of shape [n_samples, 2]
The generated samples.

yarray of shape [n_samples]
The integer labels (0 or 1) for class membership of each sample.
  1. 参数说明
    n_samples : 样本数,默认100个
    shuffle:是否随机打乱, 默认true
    noise: double 是否添加噪音
    random_state: 随机种子,给个int, 每次产生相同随机数。
返回:   X : [样本数, 2]
              y:[样本数], 0,1
  
example:
import numpy as np
from sklearn.datasets import make_moons
import matplotlib.pyplot as plt
# 手动生成一个随机的平面点分布,并画出来
np.random.seed(0)
X, y = make_moons(200, noise=0.50)
plt.scatter(X[:,0], X[:,1], s=10, c=y, cmap=plt.cm.Spectral)
plt.show()


你可能感兴趣的:(python学习,make_moons)