Comments (7)
On Fri, Dec 6, 2013 at 12:04 PM, nmearl [email protected] wrote:
Is it possible to include scipy's brute method as an option? I know this
may be rather specific -- I need to do a comparative analysis -- but I was
hoping if its not too difficult it can be done. I'm looking at the
Minimizer function now, but I don't want to muck around in there if it's
something that could be easily done by someone who knows the code better.I think it's a good idea to add "brute", but I haven't looked into this
myself. One obvious question is whether the ranges and number of samples
should be attributes of the Parameters -- that seems preferable to me, but
is probably a bit more work.
Anyway, it would be a great addition, and a good project. I'd encourage
you to look into trying this.
--Matt Newville
from lmfit-py.
I was wondering whether anyone has looked into this again or has some code to start with?
I'm afraid my own experience with Python as a whole and lmfit (or SciPy) in particular is very limited.
from lmfit-py.
from lmfit-py.
I'll give that a shot. Thanks, @andyfaff
from lmfit-py.
@slhck @andyfaff It's very interesting and timely for me that you bring this up now! In fact, I was having a conversation in my lab yesterday about setting up an auto-focus-like system, and the conversation turned to doing a brute-force / grid search followed by a least-squares/steepest-descent approach. But the objective function would be moving motors and measuring an image from a CCD camera, so we need to be able to impose limits on the variables (motor positions). So, using lmfit and starting with a brute force grid and then "polishing" with least-squares would be great for this.
The scipy.optimize.brute is not very long and devotes much of its space to the "polishing step", which we don't really need since we can just replace the fitting method in lmfit. So, I would suggest that we add a brute() method using Parameters and their min/max values as the bounds ourselves. Using numpy mgrid
and vectorize
would make the whole thing pretty easy, as scipy.optimize.brute shows. One could either have a single Nmesh value, implying a uniform number of points for each variable Parameter, Or perhaps allow each Parameter to have a "ngrid" attribute? It would also be nice to put the entire set of results into the MinimizerResult, so that surface-plots of parameter pairs could be easily visualized.
FWIW, differential evolution seems to me a useful but different thing. A brute-force mesh-search has the appeal of having easily predicted number of evaluations and mesh size, making it appropriate for "broad surveys of parameter space" and for giving an idea of how complicated the parameter landscape is.
Anyway, I think this should be done. I would encourage you to try doing this if you're interested, and would be willing to help.
from lmfit-py.
@newville this issue can be closed: it was added in commit 22b40fd.
from lmfit-py.
@reneeotten Thanks!
from lmfit-py.
Related Issues (20)
- Test suite: Skipped tests cause test suite failures HOT 6
- Test suite failures: Pytest fails with multiprocessing, ConstantModel has not independent_vars HOT 1
- Test suite failures: Pytest fails with multiprocessing, ConstantModel has not independent_vars HOT 1
- Test suite failures: Pytest fails with multiprocessing, ConstantModel has not independent_vars HOT 1
- Test suite failures: Pytest fails with multiprocessing, ConstantModel has not independent_vars HOT 1
- Cannot select method of scipy least_squares function HOT 6
- Model.make_params() sometimes ignores set a parameter with a prefix
- an aborted fit with `method='least_squares'` does not report correct fit results and statistics HOT 3
- ModelResult.eval_uncertainty does not work for complex models HOT 2
- loaded ModelResult bug (eval_uncertainty() not working) HOT 1
- `result.params.uvars` not correctly created with Minimize HOT 1
- jacobian matrix HOT 1
- Inconsistencies with non-parameter model function arguments HOT 1
- Retain default values for keyword arguments when manually choosing param_names
- Model.fit() gives the wrong 'rsquared' when 'weights' is given HOT 3
- OS systems where multithreading.Pool is not allowed HOT 1
- lmfit-py is affected by the uncertainities Python3.12 incompatibility HOT 9
- ModelResult loads does not work with user defined parameter expressions HOT 4
- Defining `self.min_rel_change` in confidence.py as variable
- Default `method="leastsq"` in `Model().fit()` when `Parameters` have bounds HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lmfit-py.