Sahith
Sahith

Reputation: 11

10 fold cross validation python single variable regression

How does numpy vstack work in numpy while I am splitting the data into 10 folds.

X_set = np.split(X, 10)
Y_set = np.split(Y, 10)
for i in range(len(X_set)):
   X_test= ?
   Y_test= ?

Upvotes: 1

Views: 515

Answers (1)

Ami Tavory
Ami Tavory

Reputation: 76297

It's possible to do what you've started in Numpy, but I think it's too low-level for this sort of stuff. I'd suggest you install sklearn. Then, you can do the following

from sklearn import cross_validation

for tr, te in cross_validation.KFold(len(Y_set), 10):
    x_train, y_train = X_set[tr], Y_set[tr]
    x_test, y_test = X_set[te], Y_set[te]

Upvotes: 2

Related Questions