Учитывая количество выборок n_samples
и n_splits
, когда n_sample % n_splits == 0
, мы можем выполнить четко определенную перекрестную проверку в k-кратном размере.
Удивительно, но когда я случайно установил n_samples = 40
, n_splits = 14
, KFold
все еще работает, вот мой код
from sklearn.model_selection import KFold
import numpy as np
kf_test = KFold(n_splits=14)
test_x = np.random.rand(40)
pointer = 0
for item_t, item_v in kf_test.split(test_x):
if pointer == 0:
print(item_t.shape)
print(item_v.shape)
print(len(item_v) / 40)
pointer += 1
pointer, test_x
Как работает KFold при n_samples % n_splits != 0
? Я пробовал разные значения, но не смог найти образец.