Python 如何在ML中实现make_folds函数

Python 如何在ML中实现make_folds函数,python,numpy,Python,Numpy,如何在ML中实现make_folds函数 def make_folds(x, num_folds): """ Divides the array `x` along axis-0 into a list of equal-sized sub-arrays. x是numpy数组您可以尝试以下方法: def make_folds(x, num_folds): """ Divides the array `x` a

如何在ML中实现make_folds函数

def make_folds(x, num_folds):
    """ Divides the array `x` along axis-0 into a list of equal-sized 
    sub-arrays.

x是numpy数组

您可以尝试以下方法:

def make_folds(x, num_folds):
    """ Divides the array `x` along axis-0 into a list of equal-sized 
    sub-arrays."""
    assert len(x)%num_folds == 0, "Given array can not be split into {} equal-size subarrays".format(num_folds)
    return np.split(x, num_folds)
或者如果要进行Kford验证,则直接使用