带有 SMOTE 和 Imputer 错误的管道
Pipline with SMOTE and Imputer Errors
我正在尝试创建一个首先估算缺失数据的管道,使用 SMOTE 和模型进行过采样
我的代码在我尝试 smote 之前运行良好,但我找不到任何解决方案
这里是没有smote的代码
scoring = ['balanced_accuracy', 'f1_macro']
imputer = SimpleImputer(strategy='most_frequent')
pipeline = Pipeline(steps=[('i', imputer),('m', model)])
# define model evaluation
cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1)
# evaluate model
scores = cross_validate(pipeline, X, y, scoring=scoring, cv=cv, n_jobs=-1)
这是添加smote后的代码
注意:我厌倦了从 imlearn
导入 make 管道
imputer = SimpleImputer(strategy='most_frequent')
pipeline = Pipeline(steps=[('i', imputer),('over', SMOTE()),('m', model)])
# define model evaluation
cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1)
# evaluate model
scores = cross_validate(pipeline, X, y, scoring=scoring, cv=cv, n_jobs=-1)
当我从 SKLearn 导入管道时出现此错误
所有中间步骤都应该是转换器并实现拟合和转换或者是字符串 'passthrough' 'SMOTE()'(类型 )没有
当我尝试从 imlearn 导入 makepipeline 时出现此错误
Pipeline 的最后一步应该实现 fit 或者是字符串 'passthrough'。 '[('i', SimpleImputer(strategy='most_frequent')), ('over', SMOTE()), ('m', RandomForestClassifier())]'(类型) 没有
from imblearn.pipeline import Pipeline
pipeline = Pipeline([('i', imputer),('over', SMOTE()),('m', model)])
我正在尝试创建一个首先估算缺失数据的管道,使用 SMOTE 和模型进行过采样
我的代码在我尝试 smote 之前运行良好,但我找不到任何解决方案
这里是没有smote的代码
scoring = ['balanced_accuracy', 'f1_macro']
imputer = SimpleImputer(strategy='most_frequent')
pipeline = Pipeline(steps=[('i', imputer),('m', model)])
# define model evaluation
cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1)
# evaluate model
scores = cross_validate(pipeline, X, y, scoring=scoring, cv=cv, n_jobs=-1)
这是添加smote后的代码 注意:我厌倦了从 imlearn
导入 make 管道imputer = SimpleImputer(strategy='most_frequent')
pipeline = Pipeline(steps=[('i', imputer),('over', SMOTE()),('m', model)])
# define model evaluation
cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1)
# evaluate model
scores = cross_validate(pipeline, X, y, scoring=scoring, cv=cv, n_jobs=-1)
当我从 SKLearn 导入管道时出现此错误
所有中间步骤都应该是转换器并实现拟合和转换或者是字符串 'passthrough' 'SMOTE()'(类型
当我尝试从 imlearn 导入 makepipeline 时出现此错误
Pipeline 的最后一步应该实现 fit 或者是字符串 'passthrough'。 '[('i', SimpleImputer(strategy='most_frequent')), ('over', SMOTE()), ('m', RandomForestClassifier())]'(类型
from imblearn.pipeline import Pipeline
pipeline = Pipeline([('i', imputer),('over', SMOTE()),('m', model)])