计算之道

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

获取 Scikit-Learn 中监督学习模型的方法:

from sklearn.utils import all_estimators

 

# 获取所有 Scikit-Learn 模型的列表

all_models = all_estimators(type_filter='classifier') + all_estimators(type_filter='regressor')

 

num = 0

# 打印所有模型的名称

for name, class_ in all_models:

num += 1

print(name,num)

 

上述代码通过 all_estimators 函数获取所有的分类器和回归器,并打印它们的名称。type_filter 参数用于指定筛选类型,可以选择 'classifier' 或 'regressor'。

注意,Scikit-Learn 版本更新可能会导致一些模型的名称变化或新增模型,因此建议在使用时查看官方文档以获取最新信息。

posted on 2024-02-29 16:14  计算之道  阅读(1)  评论(0编辑  收藏  举报