I have a dataset that have split into training and testing sets. First I have used K folds cross validation to tune my model. After that, I want to use every trained (K-1) folds to predict my entire testing dataset (Not the validation set that split during the cv). For example if Im using 5-folds cv, for every combination of fit of 4 folds I want to have my predictions on testing set, so in the end I want a 5-column dataframe of predictions of my testing set.
# Iterate over each foldfor train_index, _ in cv.split(x_train, y_train): # Fit the classifier on the training data for this fold svm_model.fit(x_train[train_index], y_train[train_index]) # Predict probabilities for the test data y_pred_proba_fold = svm_model.predict_proba(x_test) # Aggregate predictions from each fold y_pred_test += y_pred_proba_fold# # Average predictions over foldsy_pred_test /= cv.get_n_splits()I have tried this piece of code with the help of AI tool but it doesnt work properly.