Why I am getting different number of train size in KFold
I have the Boston
dataset from Sklearn. I am using kFold
. The value of the k
is 5. The code is given below
kf = KFold(n_splits=k, shuffle=True)
for train_index, _ in kf.split(X_train):
fitted_model = model.fit(X_train[train_index], y_train[train_index])
train_preds = fitted_model.predict(X_train[train_index])
test_preds = fitted_model.predict(X_test)
print("Train", train_preds.shape)
print("Test", test_preds.shape)
Here, I am getting a different number of train sizes. I am getting 323 for 1-4 folds and 324 for the 5th fold.
Train (323,)
Test (102,)
Train (323,)
Test (102,)
Train (323,)
Test (102,)
Train (323,)
Test (102,)
Train (324,)
Test (102,)
However, I need the same number of train sizes. Could you tell me why I am getting the different numbers of train sizes or how can I get the same number of train size in every fold?
from Recent Questions - Stack Overflow https://ift.tt/3gICHZH
https://ift.tt/eA8V8J
Comments
Post a Comment