【发布时间】:2021-07-19 02:27:03
【问题描述】:
如何在管道中访问"Log"?
pipelines = {
"Log": Pipeline(
[("scl", StandardScaler()), ("est", LogisticRegression(random_state=1))]
),
"Rf": Pipeline([("est", RandomForestClassifier(random_state=1))]),
"Rf_Pipeline": Pipeline(
[
("scl", StandardScaler()),
("reduct", PCA(n_components=10, random_state=1)),
("est", RandomForestClassifier(random_state=1)),
]
),
}
Pipelines.item(Log)
目前我得到:
NameError: name 'Log' is not defined
【问题讨论】:
-
从字典中获取条目,可以使用
pipelines["Log"]或pipelines.get("Log")。 -
您的管道名为
pipelines,而不是Pipelines,首字母大写L(错字)。 -
感谢您的修改。非常有帮助。
标签: python machine-learning scikit-learn pipeline