Python Jupyter 笔记本 scipy

马鲁姆·沃尔夫拉姆

很长一段时间以来,我能够添加数据并进行拟合,然后用数据绘制曲线。但最近我得到了这个:

   ---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-6-6f645a2744bc> in <module>
      1 poland = prepare_data(europe_data, 'Poland')
----> 2 plot_all(poland, max_y=400000)
      3 poland

~/Pulpit/library.py in plot_all(country, max_x, max_y)
     43 def plot_all(country, max_x = 1000, max_y = 500000):
     44 
---> 45     parameters_logistic = scipy.optimize.curve_fit(func_logistic, country['n'],  country['all'])[0]
     46     parameters_expo = scipy.optimize.curve_fit(func_expo,  country['n'],  country['all'])[0]
     47 

/usr/local/lib64/python3.6/site-packages/scipy/optimize/minpack.py in curve_fit(f, xdata, ydata, p0, sigma, absolute_sigma, check_finite, bounds, method, jac, **kwargs)
    787         cost = np.sum(infodict['fvec'] ** 2)
    788         if ier not in [1, 2, 3, 4]:
--> 789             raise RuntimeError("Optimal parameters not found: " + errmsg)
    790     else:
    791         # Rename maxfev (leastsq) to max_nfev (least_squares), if specified.

RuntimeError: Optimal parameters not found: Number of calls to function has reached maxfev = 800.

以下是所有 Python Jupyter Notebook 文件:https ://files.fm/u/zj7cc6ne#sign_up

如何解决这个问题?

scipy.optimize.curve_fit 采用关键字参数 p0。

参数的初始猜测(长度 N)。如果为 None,则初始值都为 1(如果可以使用自省确定函数的参数数量,否则会引发 ValueError)。

如果默认值 1 与结果相差太远,则算法可能无法收敛。尝试输入一些对您的问题有意义的值。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在jupyter笔记本python中密谋

udf与scipy在亚马逊emr jupyter笔记本上

Jupyter可以在Python笔记本中运行单独的R笔记本吗?

Python 中的缩进错误(在 Jupyter 笔记本中)

jupyter笔记本到python脚本,无格式更改

如何!rm python_var(在Jupyter笔记本中)

在jupyter笔记本中创建原始python文件

使用 python 的 Jupyter 笔记本上下文感知

如何每天自动运行python jupyter笔记本

在Jupyter Python笔记本中清除MatPlotLib图

DIY HPC集群以运行Jupyter / Python笔记本

jupyter笔记本/实验室终端python版本

选择python环境启动spyder或jupyter笔记本

在 Jupyter 笔记本中使用 Python 从 github 导入数据

将变量从Jupyter笔记本传递到python脚本

Anaconda jupyter笔记本

RCPP Jupyter笔记本

Jupyter笔记本-GPU

JupyterLab与Jupyter笔记本

我可以从具有python内核的jupyter笔记本中运行具有R内核的jupyter笔记本吗?

具有Python 2和Python3内核的Jupyter笔记本

为jupyter笔记本启用python-markdown扩展时出错

如何在我的jupyter笔记本中添加python3内核?

将我的jupyter笔记本设置为使用python版本的环境

在python jupyter笔记本中将列表转换为数据框

无法打开 Python:在 VScode 中选择解释器或 Jupyter 笔记本

如何使用jupyter笔记本查看Python类文档字符串?

如何在Python / Jupyter笔记本中省略matplotlib打印输出?

jupyter笔记本python版本2.7.13(打印无效语法错误)