Comments (4)
After thinking about it some more,
x, y = variables()
a, b = parameters()
looks weird to me. As a user I would not understand how this could possibly work. How does it know I want two? At the very least I would expect to have to give an int as argument for the number I want. So I guess in this case the sympy way is better.
Just as an aside, does the following look good?
(x, y), (a, b) = variables('x y'), parameters('a b')
I think it looks rather nice, and greatly reduces the number of lines needed! I'm thinking of adopting this as the official way of defining vars and params in the docs.
from symfit.
Some other cool ideas for the parameter factory, given that you also should have some method of specifying default values and ranges:
# value will be used as initial guess
a, b = parameters(a=1.0, b=2.0)
# Parameter will be initiated from the dict
c, d = parameters(c={'value': 1.0, 'min': 0.0}, d={'value': 2.0, 'fixed': True})
# The range of the param. Must be increasing in size. Does not support fixed kw nicely
a, e = parameters(a=(0.0, 1.0), e=(0.0, 1.1, 5.0))
# Or, taking even more inspiration from django:
c, d = parameters(c=1.0, c__min=0.0, d=2.0, d__fixed=True)
In all of these the name of the keyword argument is used as the name of the parameter.
I like a combination of the first two most: if only a number is supplied use it as an initial guess, if dict
then use that instead. The Djangoesque way is also quite nice, but only if you've seen it before I imagine.
# Next level with djangoesque syntax to keep similarity with variables():
c, d = parameters('c d', c__min=0.0, d__value=2.0, d__fixed=True)
from symfit.
Though some of these might reduce the numbers of lines of code, the main choice in what would be possible is not convenience rather than readability, since the main idea (as it strikes me) is to produce readable fitting,
With that in mind I would say that the Variables
object will have to have more input and not use introspection (?) to find the number of variables to be defined. The string added, like sympy, would be the better option, though the formatting bothers me. I would want to see (compulsory?):
x, y = Variables('x, y')
Note the added comma, which in PEP8 is the best way to represent multiple variables. It might be however, that some fuzziness should be allowed (PEP8 is a style guide) and I'm not sure on the implementation of that.
As for the Django-esque syntax, though it might be beautiful, I would at the very least not introduce it as standard. If it were possible for Django users and not be the norm, I would not object encourage it.
from symfit.
@Eljee, I agree with you that using a space as a separator is not nice. It's my other big annoyance about the way symbols are defined in sympy. (Apart from the violation of DRY)
After talking to a mutual friend of ours I decided that parameter creation shouldn't be done with optional extra's. Instead, if other default guesses or ranges are required, you can always set them separately:
a, b = parameters('a, b')
a.value = 2.0
a.min, a.max = 0.0, 10.0
I got a bit carried away earlier ;).
I still don't like the violation of DRY though... But it is the least surprising to users, which is important.
from symfit.
Related Issues (20)
- `tests/test_minimizers.py::test_multiprocessing` fails on i386 HOT 1
- sympy expression with arbitrary variables/parameters HOT 8
- Fitting custom model resulted using sympy HOT 15
- Unknown issue with super(type, obj) in fit.py HOT 3
- "Abnormal Termination in LNSRCH" Error HOT 2
- Create a Model from a constant expression returns an error HOT 2
- Model evaluation problems encountered after several derivations HOT 6
- Initial values used don't match those declared HOT 3
- Symfit errors - not fitting to data HOT 1
- Parameter and Variable shapes
- Models should be recursive
- Symbolic objectives
- Numba integration HOT 3
- No compatible with numpy 1.24.1 HOT 8
- Sensitivity of Fit's slope/max values to model parameters HOT 1
- Perform global sensitivity analysis of ODE system HOT 1
- Initial conditions for different values of independent variable HOT 2
- symfit special functions, exponential integral HOT 13
- Fitting multidimensional datasets - symfit HOT 1
- AttributeError: 'Model' object has no attribute '_cached_numerical_components'
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 symfit.