python - 从导入的模块调试 python 函数调用
问题描述
我想知道当我使用 scikit learn 库运行交叉验证时调用了哪些函数,类似于以下代码:
scores = cross_val_score(estimator=clf,
X=X_train,
y=y_train,
cv=10,
scoring='roc_auc')
特别是,我想了解在 scikit learn 中调用了什么预测函数。
解决方案
您可以使用检查模块
# import required modules
import inspect
def fun(a,b):
# product of
# two numbers
return a*b
# use getsource()
print(inspect.getsource(fun))
输出如下
def fun(a,b):两个数字的乘积返回 a*b
推荐阅读
- java - 我的 ListView 的意图没有改变我的活动
- angular - 基于模板引用将焦点设置在输入上
- php - 使用 php 对新关键字没有强制的链式方法能力
- linux-kernel - GFP_KERNEL 与 GFP_DMA 和 kmalloc() 与 dma_alloc_coherent()
- java - 安卓; 执行方法时如何显示按钮
- xcode - xcode 8 无法在 macOS 10.14 上打开
- android - 如何在android的编辑文本中显示错误消息?
- sql - Oracle SQL:向日期添加小时数
- perl - 如何在bash中分隔一列的字段?
- neo4j - Neo4J 桌面版:数据库无法重新启动:数据库 [database-f6b0d9de-9954-4197-955c-ceb200b57d92] 'v3.4.7' 退出,状态为 'KILLED'