Comments (3)
The cost functions that accept a parametric model like ExtendedBinnedNLL
use the function iminuit.util.describe(model, annotations=True)
to detect the parameters of the model (the first argument is skipped).
You can override self._parameters
in the cost function, but the intention is to add the special attribute _parameters
to your model function. This can be done even if that function is a normal Python function or a lambda, because in Python everything is an object.
def my_model(x, *args): ...
# use my model with 3 parameters
my_model._parameters = {x: None, a: None, b: None, c: None}
nll = ExtendedBinnedNLL(counts, bin_edges, my_model)
Minuit(nll, ...).migrad() # get results for 3 parameters
# use my model with 2 parameters
my_model._parameters = {x: None, a: None, b: None}
nll = ExtendedBinnedNLL(counts, bin_edges, my_model)
Minuit(nll, ...).migrad() # get results for 2 parameters
Your solution works as well, but I don't think it is a good idea to add a public interface for this.
I don't want normal users to set parameters manually, because this is supposed to be handled behind the scenes by iminuit. For experts like you who need this, there is the option to provide the special _parameters
attribute. This is documented in iminuit.util.describe
.
from iminuit.
Adding a name
keyword to the constructor of the cost functions seems like a possibility to me, but I need to think about the possible consequences.
from iminuit.
Thanks for the detailed explanation and for pointing me towards iminuit.utils.describe
!
from iminuit.
Related Issues (20)
- Tests fail without ipywidgets HOT 3
- `_safe_log` is not safe HOT 5
- iminuit hangs when trying to visualize step function HOT 1
- Better documentation for errordef HOT 1
- arm64 test failure in test_without_numba HOT 2
- test_minimize.py fails two tests HOT 2
- Error when calling mnprofile with NumPy >= 1.24 HOT 2
- Misleading documentation for iminuit.util.make_with_signature() HOT 1
- Python 3.12 support HOT 7
- Specifying relationships between fit parameters HOT 1
- Crash in visualization HOT 4
- Bundled root version uses the imp module (removed with Python 3.12) HOT 1
- cost.LeastSquares fails with data with more than 2 dimensions HOT 1
- 1 test fails: pytest.PytestDeprecationWarning: <class 'pytest_black.BlackItem'> is not using a cooperative constructor and only takes {'parent', 'fspath'}. HOT 1
- Build fails with LTO HOT 4
- Update to trusted publisher releases
- Support keyword-only cost functions
- Feature Request: mix arguments of different-sized arrays (& floats)? HOT 3
- Error: IMinuitWarning: MIGRAD fails to converge HOT 1
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 iminuit.