Function for cross validation and oversampling (SMOTE)
问题 I wrote the below code. X is a dataframe with the shape (1000,5) and y is a dataframe with shape (1000,1) . y is the target data to predict, and it is imbalanced. I want to apply cross validation and SMOTE. def Learning(n, est, X, y): s_k_fold = StratifiedKFold(n_splits = n) acc_scores = [] rec_scores = [] f1_scores = [] for train_index, test_index in s_k_fold.split(X, y): X_train = X[train_index] y_train = y[train_index] sm = SMOTE(random_state=42) X_resampled, y_resampled = sm.fit_resample