调试来自导入模块的 python 函数调用

Debug python function call from an imported module

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

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): product of two numbers return a*b

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