pymc-examples icon indicating copy to clipboard operation
pymc-examples copied to clipboard

replace optimisation function argument of `find_MAP`

Open keesterbrugge opened this issue 3 years ago • 3 comments

res = pm.find_MAP(vars=[z], fmin=optimize.fmin_l_bfgs_b) gave me the error

/usr/local/lib/python3.7/dist-packages/fastprogress/fastprogress.py:74: UserWarning: Your generator is empty.
  warn("Your generator is empty.")

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-19-1697d3cf79ec> in <module>()
      1 smoothing = 0.5
----> 2 z_val = infer_z(smoothing)
      3 
      4 plot(x, y)
      5 plot(x, z_val)

1 frames
/usr/local/lib/python3.7/dist-packages/pymc3/tuning/starting.py in find_MAP(start, vars, method, return_raw, include_transformed, progressbar, maxeval, model, *args, **kwargs)
    133 
    134     try:
--> 135         opt_result = minimize(cost_func, x0, method=method, jac=compute_gradient, *args, **kwargs)
    136         mx0 = opt_result["x"]  # r -> opt_result
    137     except (KeyboardInterrupt, StopIteration) as e:

TypeError: minimize() got an unexpected keyword argument 'fmin'

whereas res = pm.find_MAP(vars=[z], method="L-BFGS-B") did work for me

{Insert Description}

  • [ ] Notebook follows style guide https://docs.pymc.io/en/latest/contributing/jupyter_style.html
  • [ ] PR description contains a link to the relevant issue: a tracker one for existing notebooks or a proposal one for new notebooks
  • [ ] Check the notebook is not excluded from any pre-commit check: https://github.com/pymc-devs/pymc-examples/blob/main/.pre-commit-config.yaml

Helpful links

  • https://github.com/pymc-devs/pymc-examples/blob/main/CONTRIBUTING.md

keesterbrugge avatar Jul 10 '22 12:07 keesterbrugge

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

The pre-commit is failing because the notebook (examples/case_studies/spline.ipynb) doesn't match the corresponding jupytext file (myst_nbs/case_studies/spline.myst.md). I think you should be able to install the jupytext extension (https://jupytext.readthedocs.io/en/latest/install.html), restart jupyter, open the notebook, save it, and then commit/push.

cluhmann avatar Jul 22 '22 19:07 cluhmann

You should also be able to do pre-commit run --file notebook.ipynb (with the right path to your notebook) in order to fix the issue. Ref: https://docs.pymc.io/en/latest/contributing/jupyter_style.html#pre-commit-and-code-formatting

OriolAbril avatar Jul 22 '22 22:07 OriolAbril