def split_dataset(data_set,split=0.5):
'''
According to 'spilt',split the dataset to train_set and test_set
:param data_set: a Bunch object
:param split: integer
:return: x_train, x_test, y_train, y_test:Training data and target values
'''
print('spilting dataset......')
start_time = time.time()
x_train, x_test, y_train, y_test = cross_validation.train_test_split(data_set.data, data_set.target,
test_size=split, random_state=0)
print('spilting took %.2f s' % (time.time() - start_time))
# train_set=(x_train,y_train)
# test_set=(x_test,y_test)
# return train_set,test_set
return x_train, x_test, y_train, y_test
评论列表
文章目录