我试图找出适当的方法来构建一个管道来训练一个模型,其中包括使用SMOTENC算法:
下面是我的管道当前的样子:
from imblearn.pipeline import Pipeline as Pipeline_imb
from imblearn.over_sampling import SMOTENC
categorical_features_bool = [True, True, ……. False, False]
smt = SMOTENC(categorical_features =categorical_features_bool,
random_state=RANDOM_STATE_GRID,
k_neighbors=10
,n_jobs=-1
)
preprocess_pipeline = ColumnTransformer(
transformers=[
('Winsorize', FunctionTransformer(winsorize, validate=False,
kw_args={'limits':[0, 0.02],'inplace':False,'axis':0}),
['feat_1,'Feat_2']),
('num_impute', SimpleImputer(strategy='median', add_indicator=True) ,
['feat_10,'Feat_15']),
], remainder='passthrough', #passthough features not listed
n_jobs=-1,
verbose = False
)
Model = LogisticRegression()
model_pipeline = Pipeline_imb([
('preprocessing', preprocess_pipeline),
('smt', smt),
('Std', StandardScaler()),
('classifier', Model)
])发布于 2020-09-19 02:47:21
https://datascience.stackexchange.com/questions/76470
复制相似问题