从Sklearn Pipeline获取功能名称和系数
我有一条在数据映中使用MLFLOW的管道,运行管道后我想获得功能名称和系数:
我的管道看起来像这样:
sklr_classifier = LogisticRegression(
C=97.24899142002924,
penalty="l2",
random_state=956273824,
)
model = Pipeline([
("column_selector", col_selector),
("preprocessor", preprocessor),
("classifier", sklr_classifier),
])
pipe = model.fit(X_train, y_train)
我知道我可以使用:
pipe.named_steps["classifier"].coef_.flatten()
但是我想拥有关联的功能名称。
I have a pipeline that uses mlflow in Databricks and I would like to get the feature names and coefficients after I run the pipeline:
My pipeline looks like this:
sklr_classifier = LogisticRegression(
C=97.24899142002924,
penalty="l2",
random_state=956273824,
)
model = Pipeline([
("column_selector", col_selector),
("preprocessor", preprocessor),
("classifier", sklr_classifier),
])
pipe = model.fit(X_train, y_train)
I know I can access the coefficients with:
pipe.named_steps["classifier"].coef_.flatten()
But I would like to have the associated feature names.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论