我试图返回我的逻辑回归模型系数。这是我创建模型的方式:
logreg = LogisticRegression(solver = 'liblinear')
model = GridSearchCV(logreg, cv = 3, param_grid = {
'penalty': ('l1', 'l2'),
'C': [0.5, 0.6, 0.7, 0.8, 0.9],
'max_iter': [100]
})
model.fit(X_train, y_train)
model.coef_ # here is where I get the error
# Validation (test)
y_pred = model.predict(X_test)
但我遇到了以下错误:
AttributeError: 'GridSearchCV' object has no attribute 'coef_'
我甚至尝试了.best_score_和其他函数,看能否以另一种方式找到系数。但没有成功。你知道我该如何解决吗?
refit=False
或者 2) 没有运行.fit
方法? - M Z