from sklearn.datasets import make_classification生成随机类别的数据

先看help结果,及返回的结果,就是训练用的数据

make_classification(n_samples=100, n_features=20, n_informative=2, 
n_redundant=2, n_repeated=0, n_classes=2, n_clusters_per_class=2, weights=None, 
flip_y=0.01, class_sep=1.0, hypercube=True, shift=0.0, scale=1.0, shuffle=True, random_state=None)


    X : array of shape [n_samples, n_features]
        The generated samples.
    
    y : array of shape [n_samples]
        The integer labels for class membership of each sample.

y是0~n_classes-1单个数字的集合,分别对应X的sample

X几个特征就有几列,知道三个参数就可以干活了。

>>> X, y = make_classification(n_samples=100, n_features=5, n_classes=2, random_state=42)
>>> X[:12]
array([[-0.43066755,  0.67287309, -0.72427983, -0.53963044, -0.65160035],
       [ 0.21164583, -0.84389686,  0.53479393,  0.82584805,  0.68195297],
       [ 1.09267506,  0.40910605,  1.10009583, -0.94275087, -0.98150865],
       [ 1.51990078, -0.77336118,  1.99805321,  0.15513175, -0.3853136 ],
       [-0.45390127, -2.18347304,  0.24472415,  2.59123946, -0.48423407],
       [-1.46361184,  0.37531604, -1.79532002,  0.25415746, -1.24778318],
       [ 0.88948365,  0.80742726,  0.73019848, -1.28568005,  0.13074058],
       [-1.11327862,  1.89033108, -1.92487377, -1.5598485 ,  0.18645431],
       [ 0.63174629, -0.88541844,  1.02703224,  0.68057323,  0.54709738],
       [-0.88602706, -0.83311649, -0.7173148 ,  1.31217492,  0.44381943],
       [ 0.56372286, -1.47487037,  1.15509316,  1.35536951, -0.2176812 ],
       [-1.02754411, -0.32929388, -1.05383855,  0.82600732, -0.05952536]])
>>> y[:12]
array([0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1])

For Video Recommendation in Deep learning QQ Group 277356808

For Speech, Image, Video in deep learning QQ Group 868373192

I'm here waiting for you

你可能感兴趣的:(python)