I'm trying to save all iteration of my KFold 'test data, class, and predicted result' in one dataframe, but it returns ValueError: Shape of passed values is (1534, 3), indices imply (1, 3). How can I fix this?
My code :
for train_index, test_index in kf.split(X):
X_train, X_test = X.iloc[train_index], X.iloc[test_index]
y_train, y_test = y.iloc[train_index], y.iloc[test_index]
model.fit(X_train, y_train)
pred = model.predict(X_test)
d = {'Tweet': X_test, 'Sentimen': y_test, 'Predicted': pred}
df_test = pd.DataFrame(data=d, index=[0])
df_test
Things to note :
- The Dataframe is just a means to make it looks neat and organized and easier to compare between the class and the predicted result. It can be in other format as long it can achieve the same result (e.g: CSV or Excel files).
- I'm trying to save all iteration and not only the last one. I read it use concat or append to achieve this, but I don't know how implement it inside a loop and with one dataframe.