如何使用符号回归遗传编程为多重回归修复Python / DEAP代码?

时间:2018-06-19 11:49:02

标签: python linear-regression genetic-programming deap

初学者在这里。我一直在尝试使用遗传编程技术来为数据创建最佳的多元回归模型。 This是整个代码的链接。我不明白为什么我的协方差值这么低。当前基于的模型方程为:

c1*x + c2*y + c3*z

运行代码后收到的错误消息如下:

`F:\Documents>python gp_three.py
C:\Users\Dr.Siva Sridhar\AppData\Local\Programs\Python\Python36\lib\site-packages\deap\tools\_hypervolume\pyhv.py:33: ImportWarning: Falling back to the python version of hypervolume module. Expect this to be very slow.
  "module. Expect this to be very slow.", ImportWarning)
C:\Users\Dr.Siva Sridhar\AppData\Local\Programs\Python\Python36\lib\importlib\_bootstrap.py:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__  return f(*args, **kwds)
(3, 500)
[[ 90.          90.08016032  90.16032064 ... 129.83967936 129.91983968  130.        ] [ 20.          20.04008016  20.08016032 ...  39.91983968  39.95991984   40.        ]
 [  2.           2.00400802   2.00801603 ...   3.99198397   3.99599198
    4.        ]]
(500,)
Optimal parameters for regression model:
  [-0.08671535 -0.07615775  0.96088428]
Covariance:
 [[ 2.61480617e-35 -4.80978998e-29  4.80978054e-28]
 [-4.80979373e-29  6.35250888e-21 -6.35250869e-20]
 [ 4.80978426e-28 -6.35250869e-20  6.35250850e-19]]
[5.11351754e-18 7.97026278e-11 7.97026254e-10]Traceback (most recent call last):  File "gp_three.py", line 105, in <module>
    main()
  File "gp_three.py", line 98, in main    algorithms.eaSimple(pop, toolbox, 0.5, 0.1, 50, stats,hof)  File "C:\Users\Dr.Siva Sridhar\AppData\Local\Programs\Python\Python36\lib\site-packages\deap\algorithms.py", line 151, in eaSimple
    for ind, fit in zip(invalid_ind, fitnesses):
  File "gp_three.py", line 75, in evalSymReg
    fitness = math.sqrt( sum( map (diff_func, values_one, values_two, values_three) ) )
  File "gp_three.py", line 74, in <lambda>    diff_func = lambda x,y,z: ( func (x,y,z) -  reg_model ( [x,y,z], coeffs ) ) ** 2
  File "<string>", line 1, in <lambda>
OverflowError: math range error
`

我该如何解决?

0 个答案:

没有答案