I'm a bit lost at the moment. I correctly initialized an empty numpy array and I believe i'm using the np.append function correctly
Preds = np.empty(shape = (X_test.shape[0],10))
kf = KFold(n = X_train.shape[0], n_folds=10, shuffle = True)
for kf_train, kf_test in kf:
X_train_kf = X_train.iloc[kf_train]
Y_train_kf = Y_train.iloc[kf_train]
dt = tree.DecisionTreeClassifier(max_depth=2)
dt.fit(X_train_kf, Y_train_kf)
Preds = np.append(Preds,dt.predict(X_test))
print Preds
Just some additional info:
X_test has a shape of (9649, 24)
(After running) Preds has a shape of (192980,)
At the of this loop, Preds should have a shape of (9649,10)
Any advice would be much appreciated.
EDIT: Here is the updated solution
Preds = []
kf = KFold(n = X_train.shape[0], n_folds=20, shuffle = True)
for kf_train, kf_test in kf:
X_train_kf = X_train.iloc[kf_train]
Y_train_kf = Y_train.iloc[kf_train]
dt = tree.DecisionTreeClassifier(max_depth=2)
dt.fit(X_train_kf, Y_train_kf)
Preds.append(dt.predict(X_test))
Preds = np.vstack(Preds)
ValueError: all the input arrays must have same number of dimensions