纯随机采样(train_test_split)和分层采样(StratifiedShuffleSplit)| sklearn库实现
Scikit-Learn 提供了一些函数,可以用多种方式将数据集分割成多个子集。sklearn.model_selection.train_test_split是纯随机的取样方法,即没有对原数据集进行分层,具体调用如下:from sklearn.model_selection import train_test_splittrain_set, test_set = train_test_split(data, test_size=0.2, random_state=42)其中,random_s