如何从GridSearchCV创建的模型中提取feature_importances_
和{auc
)是不同的。在
pipelines = {
'rf' : make_pipeline(StandardScaler(),
RandomForestClassifier(random_state=521)),
'l1' : make_pipeline(StandardScaler(), LogisticRegression(penalty='l1' ,
random_state=521))
}
rf_hyperparams = {
'randomforestclassifier__n_estimators': [100, 110],
'randomforestclassifier__max_features': ['auto', 'sqrt']
}
l1_hyperparams = {
'logisticregression__C': np.linspace(1e-3, 10)
}
hyperparams = {
'rf' : rf_hyperparams,
'l1' : l1_hyperparams
}
fitted = {}
for name, pipeline in pipelines.items():
model = GridSearchCV(pipeline, hyperparams[name], cv=10, n_jobs=-1)
model.fit(X_train, y_train)
fitted[name] = model
目前没有回答
相关问题 更多 >
编程相关推荐