make_hastie_10_2#
- sklearn.datasets.make_hastie_10_2(n_samples=12000, *, random_state=None)[source]#
生成用于二元分类的数据,源自 Hastie 等人 2009 年的示例 10.2。
十个特征是标准独立高斯分布,且目标
y
定义为y[i] = 1 if np.sum(X[i] ** 2) > 9.34 else -1
在 用户指南 中了解更多。
- 参数:
- n_samplesint, 默认值=12000
样本数量。
- random_stateint, RandomState 实例或 None, 默认值=None
确定数据集创建的随机数生成。传入一个整数以在多次函数调用中获得可重现的输出。参见 术语表。
- 返回:
- X形状为 (n_samples, 10) 的 ndarray
输入样本。
- y形状为 (n_samples,) 的 ndarray
输出值。
另请参见
make_gaussian_quantiles
该数据集方法的泛化。
参考文献
[1]T. Hastie, R. Tibshirani 和 J. Friedman, “Elements of Statistical Learning 第2版”, Springer, 2009。
示例
>>> from sklearn.datasets import make_hastie_10_2 >>> X, y = make_hastie_10_2(n_samples=24000, random_state=42) >>> X.shape (24000, 10) >>> y.shape (24000,) >>> list(y[:5]) [np.float64(-1.0), np.float64(1.0), np.float64(-1.0), np.float64(1.0), np.float64(-1.0)]