Comments (10)
Michael wrote:
"_Thinking about doing some brute-force parameter space exploration around points returned by optimisers. Need to do it in 2D/3D so I can visualise though. Would it be enough to plot parameter 1 & parameter 2, parameter 3 & parameter 4 etc. Or should I do plots for all possible combinations (like the triangular MCMC plots?)
_"
Jonathan wrote:
"Depends what you want to use it for I guess. Doing all combinations will give you a better feel for what's going on, and just involves more plots, not more computation.
You could perhaps figure out which pairs give the most interesting surface (biggest changes in likelihood) and plot those first?"
@martinjrobins wrote:
"@michael r u implementing this in pints? I'd like to do this as well, so it would be nice to have this as a general plot_likelihood_around_point() type function"
from pints.
Thinking it could be good to have this in a box (i.e. boundaries / uniform prior) and then uniformly spaced. If we make it more complicated it stops being a check and becomes a bad version of mcmc or other samplers
from pints.
Turns out I have this in Myokit (but have deprecated it because fitting isn't a core goal there)
def map_grid(f, bounds, n, parallel=False, args=None):
"""
Maps a parameter space by evaluating every point in a rectangular grid.
Arguments:
``f``
A function to map. The function ``f(x)`` must be callable with ``x`` a
sequence of ``m`` coordinates and should return a single scalar value.
``bounds``
A list of ``m`` tuples ``(min_i, max_i)`` specifying the minimum and
maximum values in the search space for each dimension ``i``. The mapped
space will be within these bounds.
``n``
The number of points to sample in each direction. If ``n`` is a scalar
the function will map a grid of ``n`` points in each direction, so that
the total number of points is ``n**m``, where ``m`` is the
dimensionality of the search space. Alternatively, the number of points
in each dimension can be specified by passing in a length ``m``
sequence of sizes, so that the total number of points mapped is
``n[0] * n[1] * ... * n[m-1]``.
``parallel``
Set to ``True`` to run evaluations on all available cores.
``args``
An optional tuple containing extra arguments to ``f``. If ``args`` is
specified, ``f`` will be called as ``f(x, *args)``.
Returns a tuple ``(x, fx)`` where ``x`` is a numpy array containing all the
tested points and ``fx`` contains the calculated ``f(x)`` for each ``x``.
"""
# Check bounds, get number of dimensions
ndims = len(bounds)
if ndims < 1:
raise ValueError('Problem must be at least 1-dimensional.')
for b in bounds:
if len(b) != 2:
raise ValueError(
'A minimum and maximum must be specified for each dimension.')
# Check number of points
try:
len(n)
except TypeError:
n = (n,) * ndims
if len(n) != ndims:
if len(n) == 1:
n = (n,) * ndims
else:
raise ValueError(
'The positional argument n must be a scalar or provide a value'
' for each dimension.')
npoints = np.array(n)
ntotal = np.prod(npoints)
# Create points
x = []
n = iter(npoints)
for xmin, xmax in bounds:
x.append(np.linspace(xmin, xmax, next(n)))
# Create a grid from these points
x = np.array(np.meshgrid(*x, indexing='ij'))
# Re-organise the grid to be a series of nd-dimensional points
x = x.reshape((ndims, ntotal)).transpose()
# Evaluate and return
return x, evaluate(f, x, parallel=parallel, args=args)
Should we include something like this in Pints?
from pints.
Maybe latin hypercube sampling too
from pints.
And sobol sampling
from pints.
Or perhaps we should implement these as methods inside the UniformPrior
. Touches on what we discussed today a bit. Any thoughts @ben18785 @martinjrobins ?
from pints.
from pints.
I think so! But that sounds suspiciously like you're inventing a sampler :D
from pints.
@MichaelClerx Do we still want this? I'm not sure about it since uniformly sampling a space is easy enough to do and doesn't work well in anywhere above a handful of dimensions.
from pints.
I'm still thinking it could be very useful e.g. to explore and plot score functions.
Perhaps as several sampling methods on the bounded uniform prior, or something like that.
I also like the idea of having a sort of zero-cleverness brute-force approach as a baseline to compare stuff with (even if that means the method doesn't really work for most cases)
And this is something I've done and found useful in the past, so I'd like to keep this ticket open
from pints.
Related Issues (20)
- Transformed rectangular boundaries HOT 5
- Chained transformations
- UnitCubeTransformation or ScalingTranslationTransformation
- ScalingTransformation has visible properties, could do with better docs
- Add and fix HABC sampler using SGHMC HOT 1
- Header of logged "time" field is wrong HOT 3
- Can't reproduce Stochastic Degradation model: No module named 'pints.toy.stochastic' HOT 4
- NUTS coroutines don't work on Python 3.11 HOT 5
- badges not displaying in readme.md
- Settings of XNES HOT 2
- Likelihood for censored data
- Docs for ErrorMeasure and other base classes should show __call__
- Create GaussianIntegratedLogUniformLogLikelihood
- Anyone mind if we rename `master` to `main` ? HOT 1
- Docs no longer build HOT 1
- Change optimiser examples to use OptimisationController directly
- Add PRIMA optimisers HOT 2
- Deprecation warning: pints.UniformLogPrior HOT 1
- Add reciprocal distribution prior (LogUniformLogPrior) to help estimate parameters that vary over multiple orders of magnitude HOT 1
- Add "xtol" and "ftol" stopping criteria for optimisers HOT 11
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 pints.