在调用 SMOTENC 之前对连续和分类特征进行数据缩放
Data scaling before call SMOTENC for continuos and categorical features
到目前为止,我的代码如下 运行 SMOTENC。
from imblearn.over_sampling import SMOTENC
smt = SMOTENC(random_state=seed, categorical_features=[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53], ratio=1.0, n_jobs = -1)
# n_jobs = The number of threads to open if possible. ``-1`` means using all processors.
# default K=5
X_res, y_res = smt.fit_sample(X_tra, y_tra)
这里的问题是我正在阅读有关 SMOTE 的内容,因为它使用具有欧氏距离的 KNN 算法,所以在调用 SMOTENC()
之前应该缩放数据。
如果数据集的前 10 个特征为整数,其余为分类特征,在这种情况下我应该如何进行缩放过程?
我建议根据您的数据分布使用 MinMaxScaler
或 StandardScaler
来缩放 numerical/continuous 特征。
关于分类特征,这不是选择 SMOTENC
而不是 SMOTE
算法的重点吗?
到目前为止,我的代码如下 运行 SMOTENC。
from imblearn.over_sampling import SMOTENC
smt = SMOTENC(random_state=seed, categorical_features=[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53], ratio=1.0, n_jobs = -1)
# n_jobs = The number of threads to open if possible. ``-1`` means using all processors.
# default K=5
X_res, y_res = smt.fit_sample(X_tra, y_tra)
这里的问题是我正在阅读有关 SMOTE 的内容,因为它使用具有欧氏距离的 KNN 算法,所以在调用 SMOTENC()
之前应该缩放数据。
如果数据集的前 10 个特征为整数,其余为分类特征,在这种情况下我应该如何进行缩放过程?
我建议根据您的数据分布使用 MinMaxScaler
或 StandardScaler
来缩放 numerical/continuous 特征。
关于分类特征,这不是选择 SMOTENC
而不是 SMOTE
算法的重点吗?