如何利用scikit-learn生成8个二维数据集,代码是什么
时间: 2024-05-13 17:20:25 浏览: 46
一个使用Python中的scikit-learn库实现的简单K-Means聚类算法脚本
以下是生成8个二维数据集的示例代码:
```
from sklearn.datasets import make_classification, make_moons, make_circles, make_blobs, make_gaussian_quantiles
# 生成2分类数据集
X1, y1 = make_classification(n_samples=100, n_features=2, n_informative=2,
n_redundant=0, n_clusters_per_class=1, random_state=1)
# 生成2个半月形数据集
X2, y2 = make_moons(n_samples=100, noise=0.1, random_state=1)
X3, y3 = make_moons(n_samples=100, noise=0.2, random_state=2)
# 生成2个圆形数据集
X4, y4 = make_circles(n_samples=100, noise=0.1, factor=0.5, random_state=1)
X5, y5 = make_circles(n_samples=100, noise=0.2, factor=0.5, random_state=2)
# 生成2个高斯分布数据集
X6, y6 = make_gaussian_quantiles(n_samples=100, n_features=2, n_classes=2, random_state=1)
X7, y7 = make_gaussian_quantiles(n_samples=100, n_features=2, n_classes=2, random_state=2)
# 生成2个随机斑点数据集
X8, y8 = make_blobs(n_samples=100, centers=2, n_features=2, random_state=1)
X9, y9 = make_blobs(n_samples=100, centers=2, n_features=2, random_state=2)
```
阅读全文