Scipy优化最小化错误输出

问题描述

尝试使用 scipy optimize 进行基本最小化,当我使用 fminbound 或 minimum_scalar 时它工作得很好,但偶尔我会陷入局部最小值,因此我需要使用 minimum() 来循环遍历不同的起点。当我使用最小化时,我收到两条消息之一和错误的输出。我要么得到:

 message: b'CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH'

或:

 message: b'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL'

我只是在一个看起来像这样的函数中最小化平方和误差 SSE:

def sse_f(alpha):
    data = []
    for _,row in temp.iterrows():
        pc[idx] += (alpha*prediction_error)
        #calculate diff variables removed for simplicity 
        data.append([phase,pi,PE])
    col = ['phase','abs_PE','congruency']
    df_ = pd.DataFrame(data,columns= col)
    df_a = df[(df['phase']=='a')]
    x = np.array(df_a[['congruency','abs_PE']]) #run linear regression for first half
    y = df_a['RT'] 
    sse = lin_reg(x,y)
    return sse 

这是我用来运行最小化函数的行:

start = [0]
minimize(sse_f,start,method='L-BFGS-B',bounds=[(0,1)])

感谢任何指点,谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...