猿问

将参数传递给 scipy.stats.binned_statistic 的用户函数

我在用


def findT(values, passFraction):

    #...<skipping func body>


def findT90(values):

    return findT(values, 0.9)    


frac90_result = scipy.stats.binned_statistic(m_test, [y_pred], bins=5, range=(0,1),

 statistic=findT90)

但我想对此进行概括,以便我可以传递任何其他值来代替0.9而不必创建新函数。passFraction调用时如何包含 值scipy.stats.binned_statistic


侃侃尔雅
浏览 222回答 1
1回答

森林海

binned_statistic 仅支持单参数函数。因此,要么做你所做的,要么即时创建一个需要的功能:binned_statistic(..., statistic=lambda values: findT(values, 0.9))
随时随地看视频慕课网APP

相关分类

Python
我要回答