python - 在 SkLearn 中打印 Estimator 名称

标签 python model scikit-learn

在 Sklearn 中,有没有办法打印出估算器的类名?

我已尝试使用 name 属性,但它不起作用。

from sklearn.linear_model import LogisticRegression  

def print_estimator_name(estimator):
    print(estimator.__name__)

#Expected Outcome:
print_estimator_name(LogisticRegression())

我希望这能打印出上面的分类器名称

最佳答案

我认为您正在寻找 estimator.__class__.__name__ 即:

from sklearn.linear_model import LogisticRegression

def print_estimator_name(estimator):
    print(estimator.__class__.__name__)

#Expected Outcome:
print_estimator_name(LogisticRegression())

关于python - 在 SkLearn 中打印 Estimator 名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54049587/

相关文章:

python - Scapy 原始套接字

python - 使用蒙特卡洛方法绘制 Pi

model-view-controller - 在joomla的 View 中调用模型函数?

python - 如何从多个向量构造 numpy 数组,其中数据按 id 对齐

python - 如何对多列使用 OneHotEncoder 并自动为每列删除第一个虚拟变量?

python - 为什么 Python 3 找不到已安装的包(例如 BeautifulSoup4)?

Python - Win32Com - 如何从 Excel 电子表格单元格中提取超链接?

java - 如何在 Java 中创建模糊逻辑规则或模型

c# - XNA Monogame 加载简单的 FBX 模型

python - 使用 sklearn KNN 显示最近邻居