我在Numba中对此错误的研究中没有看到这种特定情况.这是我第一次使用这个包,所以它可能是显而易见的.
我有一个函数,通过在称为数据的数据框中添加,相乘和/或划分每一列来计算数据集中的工程特征,我想测试numba是否会加速它
@jit
def engineer_features(engineer_type,features,joined):
#choose which features to engineer (must be > 1)
engineered = features
if len(engineered) > 1:
if 'Square' in engineer_type:
sq = data[features].apply(np.square)
sq.columns = map(lambda s:s + '_^2',features)
for c1,c2 in combinations(engineered,2):
if 'Add' in engineer_type:
data['{0}+{1}'.format(c1,c2)] = data[c1] + data[c2]
if 'Multiply' in engineer_type:
data['{0}*{1}'.format(c1,c2)] = data[c1] * data[c2]
if 'Divide' in engineer_type:
data['{0}/{1}'.format(c1,c2)] = data[c1] / data[c2]
if 'Square' in engineer_type and len(sq) > 0:
data= pd.merge(data,sq,left_index=True,right_index=True)
return data
当我用功能列表,engineer_type和数据集调用它时:
engineer_type = ['Square','Add','Multiply','Divide']
df = engineer_features(engineer_type,features,joined)
我收到错误:对象失败(分析字节码)
‘DataFlowAnalysis’对象没有属性’op_MAKE_FUNCTION’
最佳答案 同样的问题在这里我认为问题可能是自
numba does not support function creation.以来的lambda函数