老师您好:我安装您之前答复他人的帖子用GridSearchCV对PolynomialLogisticRegression网格搜索出现一个问题
来源:1-1 什么是机器学习
qq_慕姐45445
2021-06-25
def PolynomialLogisticRegression(degree = 1, C = 0.1):
return Pipeline([
(‘poly’, PolynomialFeatures(degree=degree)),
('log_reg', LogisticRegression(C=C))
])
poly_log_reg = PolynomialLogisticRegression()
C_PARM = [0.01,0.03,0.05,0.08,0.1]
param_grid_log = [
{
‘poly__degree’: [i for i in range(1, 4)],
‘log_reg__C’: [i for i in C_PARM]
}
]
grid_search_log = GridSearchCV(poly_log_reg, param_grid_log)
grid_search_log.fit(x_train1,y_train)
print(grid_search_log.best_estimator_)
当我把degree设置在1到4后就报错。而在3以下则正常获得最优degree都是1.
这个报错说明了什么问题?
写回答
1回答
-
liuyubobobo
2021-06-25
对于你的数据,在 degree = 4 的时候没有收敛。根据提示,你需要手动设置一个更大的 max_iter 的值。(默认 100 太小了,试一下 1000 甚至 10000).
继续加油!:)
022021-08-01
相似问题