问题:在实现 SMOTE(一种过采样)时,我的数据框正在转换为 numpy 数组)。
Test_train_split
from sklearn.model_selection import train_test_split
X_train, X_test, y_train_full, y_test_full = train_test_split(X, y, test_size=0.20, random_state=66)
[IN]type(X_train)
[OUT]pandas.core.frame.DataFrame
在 SMOTE 之后,X_train 的数据类型从 pandas 数据帧变为 numpy 数组
from imblearn.over_sampling import SMOTE
sm = SMOTE(random_state = 42)
X_train, y_train = sm.fit_sample(X_train, y_train)
[IN]type(X_train)
[OUT]numpy.ndarray
预期输出 我想在 SMOTE 之后保留 X_train 和 X_test 的数据帧结构。怎么做?