python - Sklearn - 通过管道传递并包装在 GridSearchCV 中后访问标量属性

标签 python machine-learning scikit-learn

我有一个管道,像这样传递给 GridSearchCV,如何从 clf 访问缩放器的属性?

pipe = Pipeline([
        ('scale', MinMaxScaler()),
        ('clf', tree.DecisionTreeClassifier(presort=True))
    ])

pipe_param_grid = {
            'clf__min_samples_split': [2, 4, 6],
            'clf__random_state': [38, 40, 42, 44],
            'clf__max_depth': [4],
            'clf__min_samples_leaf': [2, 4],
          }

clf = GridSearchCV(estimator=pipe,param_grid=pipe_param_grid)
  • Python:2.7.10
  • scikit-learn:0.18.1

最佳答案

想通了。我可以像这样访问步骤属性:

clf.best_estimator_.named_steps['scale'].scale_ 

关于python - Sklearn - 通过管道传递并包装在 GridSearchCV 中后访问标量属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43832147/

相关文章:

Python 3.2 使用 urllib 从 HTML 代码中删除换行符

python - 想要隐藏 "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" } from ping module output?

r - R 中两个类别的预测类别概率

python - 使用留一交叉验证进行过采样

python - EM 聚类算法中附加的标签

jquery - Flask AJAX 自动完成

python-3.x - pytorch模型加载和预测,AttributeError : 'dict' object has no attribute 'predict'

python - 是否可以在大型稀疏矩阵上使用 scikit TSNE?

python - Sci-Kit 学习 SGD 算法时出错 - "Array contains NaN or infinity"

python - xlwings:保存并关闭