admin管理员组文章数量:1389837
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
num_features, bin_features, cat_features = split_features(X)
preprocessor = ColumnTransformer([
('num', StandardScaler(), num_features),
('bin', 'passthrough', bin_features),
('cat', OneHotEncoder(drop='first', sparse_output=False, handle_unknown='ignore'), cat_features)
])
inner_pipeline = Pipeline([
('preprocessor', preprocessor),
('model', LinearRegression())
])
pipeline = TransformedTargetRegressor(
regressor=inner_pipeline,
transformer=QuantileTransformer(output_distribution='normal')
)
param_grid = {
'transformer__n_quantiles': [10, 100, 1000]
}
optimizer = GridSearchCV(pipeline, param_grid, cv=10, scoring='neg_root_mean_squared_error', n_jobs=-1)
optimizer.fit(X_train, y_train)
y_pred = optimizer.best_estimator_.predict(X_test)
I tried:
optimizer.best_estimator_.regressor.named_steps['model'].coef_
I got: AttributeError: 'LinearRegression' object has no attribute 'coef_'
本文标签: linear regressionLinearRegression object has no attr coef (in pipeline)Stack Overflow
版权声明:本文标题:linear regression - LinearRegression object has no attr coef_ (in pipeline) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744650992a2617682.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论