This question has been asked before, here and here. When I try those answers, my error message is that my model has no attribute of coef
. I use a pipeline, gridsearch, and Target Transformation. I can access the model itself, but my error message is that my model, SGDRegressor has no attribute coef_.
cv_inner = KFold(n_splits=5, shuffle=True)
params = {'model__regressor__penalty':['elasticnet']
,'model__regressor__l1_ratio': [0.1,0.3]
}
mymodel = Pipeline(steps = [('preprocessor', preprocessor),
('model', TTR(regressor=SGDRegressor(n_jobs=-1),transformer=qt))
])
optimize_hparams = GridSearchCV(
estimator = mymodel, param_grid=params, n_jobs = -1,
cv=cv_inner, scoring='neg_mean_absolute_error')
optimize_hparams.fit(X, y)
optimize_hparams.best_estimator_.named_steps['model'].regressor.coef_
# 'SGDRegressor' object has no attribute 'coef_'
question from:
https://stackoverflow.com/questions/65940390/return-coefficients-after-pipeline-gridsearch-and-target-transformation 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…