【发布时间】:2021-04-02 06:50:08
【问题描述】:
这是我的数据:
x
array([ 0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84,
91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175])
y
array([0.4 , 0.4 , 0.4 , 0.4 , 0.6 , 0.6 , 0.6 , 0.6 , 0.6 , 0.97, 0.97,
0.97, 0.97, 1.13, 1.13, 1.13, 1.13, 1.13, 0.9 , 0.9 , 0.9 , 0.9 ,
0.7 , 0.7 , 0.7 , 0.7 ])
我申请了pwlf - https://pypi.org/project/pwlf,但每次执行此代码时都会得到不同的fit_breaks:
pwlf_model = pwlf.PiecewiseLinFit(x, y ,degree=1)
pwlf_model.fit(4)
第一次运行
pwlf_model.fit_breaks
array([ 0. , 58.01861485, 60.07425168, 104.30868782,
175. ])
第二次运行
pwlf_model.fit_breaks
array([ 0. , 59.48475228, 59.67460644, 104.30594173,
175. ])
第三轮
pwlf_model.fit_breaks
array([ 0. , 56.60204 , 62.0270283 , 104.30827438,
175. ])
第四轮
pwlf_model.fit_breaks
array([ 0. , 58.92722066, 59.50363949, 104.30764284,
175. ])
这是为什么呢?模型中的任何随机步骤? [1]:https://i.stack.imgur.com/Iut9x.png
【问题讨论】:
标签: python-3.x regression linear-regression piecewise