首页 > 解决方案 > 从导入的模块调试 python 函数调用

问题描述

我想知道当我使用 scikit learn 库运行交叉验证时调用了哪些函数,类似于以下代码:

scores = cross_val_score(estimator=clf,
                             X=X_train,
                             y=y_train,
                             cv=10,
                             scoring='roc_auc')

特别是,我想了解在 scikit learn 中调用了什么预测函数。

标签: pythondebuggingscikit-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

来源:https ://www.geeksforgeeks.org/inspect-module-in-python/


推荐阅读