make_friedman2#

sklearn.datasets.make_friedman2(n_samples=100, *, noise=0.0, random_state=None)[原始碼]#

產生 “Friedman #2” 迴歸問題。

此資料集在 Friedman [1] 和 Breiman [2] 中描述。

輸入 X 是 4 個獨立特徵,均勻分佈在以下區間:

0 <= X[:, 0] <= 100,
40 * pi <= X[:, 1] <= 560 * pi,
0 <= X[:, 2] <= 1,
1 <= X[:, 3] <= 11.

輸出 y 根據以下公式建立:

y(X) = (X[:, 0] ** 2 + (X[:, 1] * X[:, 2]  - 1 / (X[:, 1] * X[:, 3])) ** 2) ** 0.5 + noise * N(0, 1).

請在 使用者指南 中閱讀更多內容。

參數:
n_samplesint,預設值為 100

樣本數量。

noisefloat,預設值為 0.0

應用於輸出的高斯雜訊的標準差。

random_stateint, RandomState 實例或 None,預設值為 None

決定資料集雜訊的隨機數生成方式。傳入整數可確保多次函式呼叫時產生可重現的輸出。請參閱詞彙表

回傳值:
X形狀為 (n_samples, 4) 的 ndarray

輸入的樣本。

y形狀為 (n_samples,) 的 ndarray

輸出的數值。

參考文獻

[1]

J. Friedman, “Multivariate adaptive regression splines”, The Annals of Statistics 19 (1), pages 1-67, 1991.

[2]

L. Breiman, “Bagging predictors”, Machine Learning 24, pages 123-140, 1996.

範例

>>> from sklearn.datasets import make_friedman2
>>> X, y = make_friedman2(random_state=42)
>>> X.shape
(100, 4)
>>> y.shape
(100,)
>>> list(y[:3])
[np.float64(1229.4...), np.float64(27.0...), np.float64(65.6...)]