scipy最小化在优化过程中不探索所有样本空间

2024-09-28 01:30:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我只想优化函数的两个参数alphabeta,我正在使用scipy.optimize.minimize函数和TNC算法。目标函数为观测值与预测值的均方误差。在优化过程中,alpha和beta可以在0.1和0.99之间变化。我观察到scipy.minimize只探索有限的样本空间。 enter image description here

在优化过程中,错误函数表现如下

enter image description here

这是否意味着算法陷入局部极小

优化参数如下:

anfangwerte = np.array([0.9, 0.6])  # initial values of alpha and beta
grenze = (
    (0.1, 0.99),  # bounds for alpha
    (0.1, 0.99)   # bounds for beta
     )

res = minimize(model.objective_function,  # it returns mean square error
               x0=anfangwerte,
               method='TNC',       # 'TNC',
               tol=0.002,    #
               bounds=grenze,
               options={
                   'eps': 1e-2,      # default 1e-8
                   'scale': None,
                   'stepmax': 15,
                   'disp': True,
                   'maxiter': 100,
                   'accuracy': 0.00004,
                   'gtol': 0.00002,
                   'ftol': 0.00002
               }
               )

为什么算法只探索有限的样本空间?我应该为此更改哪个参数

通过稍微改变初始值和优化参数,该模型确实探索了更多的样本空间。我使用0.1和0.99作为参数和样本空间的初始值,如下所示 enter image description here

有趣的是,该模型仍然收敛到相同的MSE,即167。 enter image description here

我仍然看到许多样本空间未被探索。我们怎么能假设函数已经找到了全局极小值


Tags: 函数模型alpha算法for参数过程scipy

热门问题