Skip to the content.

當我們需要更大量的資料來做測試的時候,我們可以使用 scikit learn 提供的自動生成數據。

Generated datasets 生成的數據集

因為使用方法很類似我們來看幾個實際使用的範例。

from sklearn.datasets import make_classification

X, y = make_classification(n_samples=1000, 
                   n_features=7,
                   n_informative=4,
                   n_classes=3)

X.shape, y.shape

from sklearn.datasets import make_regression

X, y = make_regression(n_samples=1000, 
                   n_features=7,
                   n_targets=2,
                   random_state=87)

X.shape, y.shape
from sklearn.datasets import make_regression

X, y = make_regression(n_samples=100, 
                    n_features=4, 
                    n_targets=2,
                    random_state=87)

X.shape, y.shape

from sklearn.datasets import make_blobs
X, y = make_blobs(n_samples=100, 
                centers=3, 
                n_features=2,
                random_state=87)

X.shape, y.shape